Command Line Apps "Beach ball"

I find myself writing a lot of scripts at work lately that generate
reports on the command line. I was thinking it might be kind of fun
to have a "beach ball" effect on the cursor to let the user know stuff
is happening. For example, I remember install screens for DOS
programs used to have the pipe character "spin" around. Is there a
library that handles this sort of thing?

James

I find myself writing a lot of scripts at work lately that generate
reports on the command line. I was thinking it might be kind of fun
to have a "beach ball" effect on the cursor to let the user know stuff
is happening. For example, I remember install screens for DOS
programs used to have the pipe character "spin" around. Is there a
library that handles this sort of thing?

If you have a reasonable normal shell you could do this:

spinners = ['|', '/', '-', '\\']
printf "%s", spinners[0]
STDOUT.flush
1.upto(1000) do |i|
   printf "\b%s", spinners[i % spinners.size]
   STDOUT.flush
   sleep(0.1)
end

Works on OSX's bash anyway... I'm sure someone out there can condense that into one line :slight_smile: Replace the sleep() call with something that takes awhile to process otherwise all you see is a blur.

-philip