Thursday, April 11, 2013

Thoughts on loading ... loading ... loading ... done

Almost all of the coding that I do is command line based. I work in an environment where pretty much everything has to be accessed via the command line, and even when we do work with a GUI, it typically is to set up a command line string to be passed to a system call. That is just the nature of the work when you operate in a batch environment.

Anyway, back to my point, sometimes there are times when I have to watch a screen doing some boring stuff like tell my how many of my 12k files have been copied over to the work space before the job can start. For things like this I would kind of like a more interesting screen than:

100 of 12224 files copied
200 of 12224 files copied
300 of you get the picture.

I think I may start to work on a library (written in C, probably using ncurses) to do some text based animations.  There are a few which were interesting in a thread over at stack overflow which could be kind of neat, but few of them actually give information about the progress of the process.

I had some ideas, like a bulge going through a pipe and filling up a bucket, along with some information about the progress.  An example might look something like:

 
---------/ \----\
---------\_/---\ \
             |     |
             |     |
 x of y      |-----|
 items       |     |
             +-----+

Another option would be something along the lines of files flying toward something, maybe a giant mouth that wants to eat it:

 
                           /-----\
               ____       / o     \
        --    /   /       +--\     \
       --    /___/            |    |
________________________  +--/     /
     #.# % done           \       /
     x of y items          \-----/


Another one which I won't draw out here at all, but I thought was funny was a cow which eats some grass on one side of the screen, then moves over to the other side of the screen and, um, deposits the grass in a slightly altered form.

I figure the API would look something along the line of:
 
    int pipe(int progress, // the number of items / tasks which have finished
             int max,      // the to total number of items to be done
             int substeps, // the number of steps to generate for an animation
             const char* itemName); // replaces 'items' above

Of course, I am by no means tied to this API, and it may even make sense to make the library in C++ so that a single animation could be considered an object, making it easier to have state.

Finally, while this was inspired by something at work, it is by no means appropriate for me to develop while at work. Though if I do get it developed on my own time, and like the results, I have no problem with incorporating it into my projects at work. I'm welcome to other ideas for animations, API, or any other form of help/support.

1 comment:

  1. simulate the trench scene from 'A New Hope' have it be the view from the cockpit of the x wing. Have the x wing get shot each time a step is done. Have a indicator that shows the x wing's "shields" and have it be the progress bar. When you get to the end if the script had no errors, blow up the death star. If there were errors, blow up the x wing. 8-)

    ReplyDelete