Hacker News new | ask | show | jobs
by lobster_johnson 3365 days ago
This is good stuff, but what I'm really looking for, which apparently doesn't exist, is a terminal lib that doesn't take over the whole screen.

I want to be able to insert temporary widgets that can then be removed, and I want to continue to treat the terminal as a long ream of text. For example, like this:

    $ my-program --verbose

    Hello! Enter a choice:

    > 1. Intergalactic warfare
      2. The Egyptian Book of the Dead
      3. Meatballs
The user should be able to use the keyboard's arrow keys to select stuff. When selected, I want the remove the whole menu and continue from there:

    $ my-program --verbose

    Thanks, you selected meatballs.

     Grinding meat
    * Heating         [######---] 5%
    * Mixing spices   [##-------] 15% (5g/sec)
      Packaging
      Shipping
When that, which is a kind of multi-step progress bar, is done, I want to delete and continue. And so on.

I also want to show prompts, with autocompletion ("dropdowns"), and other things you typically want to users to be able to do.

If anyone has seen Docker's CLI, they do something like this, by writing one line per layer and updating each line in parallel, but without taking over the screen. I assume they use some ANSI escape sequences to position the cursor, but I've never investigated.

I haven't found anything which packages the above functionality into a nice library, however.