

TTY: Ruby gem for building command line apps - pmurach
http://peter-murach.github.io/tty/

======
pipeep
The question-and-answer system seems similar to node's inquirer module:

[https://github.com/SBoudrias/Inquirer.js](https://github.com/SBoudrias/Inquirer.js)

There's a re-implementation of that same idea for python:

[https://github.com/magmax/python-inquirer](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.

~~~
pmurach
Thanks for the links, I will take a look. The future goal, idea is to create
separate repositories dealing with specifics of command line apps. So for
instance, in future I'd extract the prompt inquirer to be a separate gem
called 'tty-inquirer' or similar.

------
lobster_johnson
Looks nice! I have been thinking of extracting some code into a gem like this;
now I might not have to.

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.

~~~
pmurach
Thanks for you comment! Your feature requests are definitely where I want the
library to go so I went and added them to tracker [https://github.com/peter-
murach/tty/issues](https://github.com/peter-murach/tty/issues) as a future
reminder. Please feel free to submit more suggestions or PR!

Few people pointed out the broken website to me, I'll definitely fix. I

------
bstar77
Over the past couple years I've been building little libraries in ruby for a
boxing simulator I plan to make some day. I've already built the name
generator, region generator, coordinate system for the ring movement, json
file db, etc.

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!

~~~
pmurach
Sounds interesting! If you come to use the library and have any thoughts or
features requirements please post them on the issue tracker.

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.

------
bmn_
There's stuff in TTY that does not belong in core (table rendering, logging),
and there is a great lack of features that is available by default in [MooseX-
App]([http://p3rl.org/MooseX::App](http://p3rl.org/MooseX::App)): bash
completion, typo detection/suggestions, command words (à la `git foo`, `svn
foo`).

TTY's choice of eliminating dependencies is short-sighted. By embracing
dependencies, a library can be more powerful, have more features, solve more
problems.

~~~
pmurach
I've started TTY library as an extraction from another project. It was born
out of necessity to keep things that are generic in another place. Even more
so, a lot of TTY library is devoted to supporting table rendering, surprising
or not it involves terminal properties detection, ansi strings handling etc...

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](https://github.com/peter-
murach/equatable) library. So I definitely agree with you and think this is
the direction I'm gonna go!

------
habosa
Looks great, I will probably use this to make scripts at work.

Note: the side-nav on the Usage page ([http://peter-
murach.github.io/tty/usage/](http://peter-murach.github.io/tty/usage/))
doesn't work for me. I can only get to Table Creation.

~~~
pmurach
Sorry, I didn't have time to finish the usage page but the following readme
should be comprehensive [https://github.com/peter-
murach/tty](https://github.com/peter-murach/tty)

------
transfire
ANSI gem does a lot of this already
[http://rubyworks.github.com/ansi](http://rubyworks.github.com/ansi). I'm
always a bit leery of all-in-one libraries. If libraries have good SOC then
it's nice to be able to mix and match.

~~~
pmurach
I agree, all-in-one proposition is not my style either. From what I can tell
the ANSI gem deals only with ansi strings transformations. This library has
ansi string coloring but only to support output colorization for the shell.

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](https://github.com/erikhuda/thor) or
[https://github.com/leejarvis/slop](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.

~~~
pmurach
In future I will break dependencies out into smaller components such as tty-
prompt tty-table tty-terminal etc... which should help in mixing and matching
what you need and the tty gem itself may be just a meta gem that pulls them
all in.

------
AJAlabs
Right on! This is a project I'll be keeping an eye on!

~~~
pmurach
If you find any issues, or have suggestions then please write up on the
[https://github.com/peter-murach/tty/issues](https://github.com/peter-
murach/tty/issues) tracker.

