TTY: Ruby gem for building command line apps
peter-murach.github.io
peter-murach.github.io
https://github.com/SBoudrias/Inquirer.js
There's a re-implementation of that same idea for python:
https://github.com/magmax/python-inquirer
I've been building something recently that uses python-inquirer, although it isn't a perfect fit for my use-case. I'd be interested to know if there are any more similar libraries for python.
Features I need, though:
- Creating tables where you know the desired column widths (number of characters or percentages) but you don't know the number of rows yet, because you'd like to stream the rows, not wait for all the data until rendering.
- Display progress on a single line and the ability to clean the current line when done. Typically this is stuff like percentage/bytes completed. Spinner would be nice.
- Display an incremental series of steps that get a checkmark and turn green when ok, or display an error symbol and turn red when not.
Will see if I have time to work this into your gem.
Your site is a little broken, by the way. The API link doesn't go to any API documentation, and on the Usage page, only the table links in the sidebar work.
Few people pointed out the broken website to me, I'll definitely fix. I
The problem I've had is figuring out where I bring this all together, I've debated making it web enabled, standalone app, etc. I think I might just use this library and make it CLI based, the table library makes things really interesting for managing stats and events- I actually have a pretty strong use case for this to all be plugin based. I'd love to have my little sim running in a terminal window while I'm hacking on my web projects.
Anyway, very cool stuff, I will be investigating much deeper very soon!
On another note I suppose, the choice of the interface for a boxing simulator to be cli client is really good for prototyping and is sweet for terminal power users.
TTY's choice of eliminating dependencies is short-sighted. By embracing dependencies, a library can be more powerful, have more features, solve more problems.
Thank you for pointing me to Perl library. The only thing I would say is that TTY gem does not have option parser and will probably not have one. Its main concern is more focused on prompting for values than actually providing a way to structure command line interface. There are already libraries that do an excellent job of that. Other features I will have to look individually into. I'd love to have more input on that from yourself.
I have actually recently thought about the dependencies for this library. Originally I wanted to make it easy to vendor things but I have actually started extracting code from this lib as well. For example, the https://github.com/peter-murach/equatable library. So I definitely agree with you and think this is the direction I'm gonna go!
Note: the side-nav on the Usage page (http://peter-murach.github.io/tty/usage/) doesn't work for me. I can only get to Table Creation.
The tty gem has a rather specific scope, which is to help read data in from command line and display it in some pleasant form such as data table to the user. This library does not deal with parsing command line arguments. There area already awesome propositions out there such as https://github.com/erikhuda/thor or https://github.com/leejarvis/slop to name a few. Basically tty gem tries to fit in the middle ground between gems that are options parsers and complete solutions for structuring command line apps. It is a sort of glue for common tasks based on my experience writing command line apps.