Settings

Theme

Text-Based User Interfaces in Go – Beef up your commandline tools

appliedgo.net

20 points by christophberger 9 years ago · 5 comments

Reader

aryehof 9 years ago

Helpful article thanks. My concern with Go is that it particularly suited to problems in the space of computing, and computer and data science. Like C, suited to systems programming. What I am unconvinced about yet, is how suited it is to problems that require the modeling of concepts and their interactions, an area well suited to object domain models outside of that sweet spot. I'm aware that the alternative to an object domain model, is a database model driven by use case based procedural code, which Go could be argued to be well suited towards.

Is the "package" as the unit of encapsulation a limitation that makes Go unsuitable to the large scale modeling of concepts in problem domains outside of the "computer"?

  • christophbergerOP 9 years ago

    Go is a pragmatic language, designed for programmer productivity. I think Go was never meant to be used as a language for reasoning about models and concepts at various abstraction levels and for arbitrary problem domains. There are certainly other languages available that are better suited for this.

lobster_johnson 9 years 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.

christophbergerOP 9 years ago

Argh! Forgot to include the "golang" keyword :)

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection