
Ruby terminal apps toolkit - pmurach
http://piotrmurach.github.io/tty/
======
meow_mix
Ruby is a fantastic language for writing command line tools. String
interpolation and regex are great on it, easy to use OO principles as well as
functional principals, etc. Definitely going to be writing wrappers over some
of my favorite unix commands with this!

~~~
pmurach
Exactly my view. I'm planning to give a talk about Ruby scripting this year
and would welcome any references to the tools that people built with tty.
Please get in touch once you have anything to show.

------
niftich
A great toolkit -- there's a bunch of goodies here, but tty-table is amazing,
from the sensible API to the configurable ASCII to Unicode renderer. It
compares favorably with Hirb, the only other library I know of that draws
console tables and supports Unicode box drawing characters.

~~~
pmurach
Regarding tty-table, I have number of things planned including different
renderer types to account for more esoteric formats and also very simple
formats like tsv(table separate values) etc...

------
trishume
The progress bar gem looks pretty nice. I've been using the similar
[https://github.com/toy/progress](https://github.com/toy/progress) for a long
time and it's super useful.

One thing I prefer about progress is that the default config includes an ETA,
which is generally the thing I care most about. It's interface is also a
little nicer. It's really nice to have an estimate on when a script might
complete, so I know if I have to optimize it or if I can just leave it running
for a while.

~~~
psadauskas
Shameless plug: I wrote a progress bar gem awhile back for that exact use-
case: I wanted it to be as simple as possible to use, and show me an ETA for
completion. Maybe you'll find this one useful, too.

[https://github.com/paul/progress_bar](https://github.com/paul/progress_bar)

------
xuejie
I wonder how easy it is to port all those libraries to mruby's mrbgems, so we
can easily pack the Ruby-based CLI program as a single binary to get Go-like
benefits.

~~~
OhSoHumble
Yeah, building Golang based command line tools is a big bag of pros and cons.
There are _so_ many libraries out there for Ruby and Python but having to
manage packaging applications written in those languages can be kind of
annoying.

~~~
eikenberry
Python and Ruby really shine for scripting when the OS already has the
packages installed. Otherwise not so much and a mostly self contained binary
like Go produces would be better.

------
kondro
What does everyone suggest for command-line options parsing? This seems to be
missing from the gemset and I've never found any of the existing solutions to
be very intuitive.

~~~
jfe
hand-roll it. a 3-minute programming task doesn't warrant pulling in a graph
of dependencies a la leftpad.

~~~
matthewmacleod
Never do this. There are a basket of edge-cases and weirdness that you'll miss
in your three-minute re-implementation that aren't worth that pain you'll have
using or debugging later on.

~~~
cturner
There's a better alternative: don't have complex usage in the first place. You
can get all the functionality you want by having multiple executables calling
a common library.

Consider netcat. You read the man page, and try to do something following its
advice. Often enough, it just doesn't work. Because it's trying to cover a
range of unrelated usages through a single entrypoint.

It's easy to set up multiple exes cleanly. Have a non-executable module that
contains the functions that your application requires (e.g. call it lib.rb).
For each distinct usage, create a separate executable script that imports
lib.rb, extracts a, b and c from the for just that usage and then call
lib.usage(a, b, c).

Users will find this easy to discover. You will find it easy to maintain, even
compared to dedicated parsing DSLs.

We don't special-case functions to do multiple things based on complex
argument cases. We just create well-defined functions. We should think of
executables in the same terms.

------
PerusingAround
Is there something similar but for Python?

~~~
throwawayish
I don't think anything is missing, but you don't get it all in one package.

click ( [http://click.pocoo.org/6/](http://click.pocoo.org/6/) ) has a lot of
this stuff in one package, but not everything, eg. composable command lines,
progress bars, spinners, prompts, bash completion, colors, paging, launching
common applications ($EDITOR) 'n stuff like that.

pyinvoke has a somewhat different focus, but also quite some stuff similar to
this.

clint (
[https://github.com/kennethreitz/clint](https://github.com/kennethreitz/clint)
) is another bag of tools, with things like awesome tables, colors, progress
bars, ...

------
VeejayRampay
Looks modular, well-built and well documented. I'll definitely check it out
next I need a terminal app or script. Thanks.

~~~
piratebroadcast
What kind of terminal apps do you write? I havent had the need for one yet and
am wondering what this tool is used for.

~~~
matt4077
I have a bunch of scientific data pipelines and have found rake to be an
excellent tool for these. Same for a bunch of "housekeeping" scripts.

Rake is seriously underrated I believe. It allows for dependencies and rules,
figures out which steps are up-to-date and skips those, allows easy
parallelisation etc. Much like make, but with the familiar and sane (ye
beautiful) syntax of ruby and its extensive ecosystem.

------
dkarapetyan
I've used this toolkit. It's pretty well done. The tabular ASCII capabilities
tty-table are pretty neat.

------
transfire
Looks promising -- definitely a lot of work went into it. The closest other
gem I know of is Ruby ANSI
([http://rubyworks.github.io/ansi/#](http://rubyworks.github.io/ansi/#))

------
growt
Not sure if it's welche here, but I wrote a Seminar lib for PHP:

[https://github.com/grothkopp/PHPCliWrapper](https://github.com/grothkopp/PHPCliWrapper)

~~~
Anthony-G
“welche?” – the German word doesn’t make sense in this context so I presume
it’s another autocorrect typo (perhaps “welcome”)? If so, I upvoted your post
to show that it is welcome (and useful).

~~~
growt
thank you, you're right about "welche"->"welcome

------
throw2016
Ruby apps are by far the most time consuming to configure and install. Nothing
is simple. Nothing just works.

The whole idea of exposing end users to your apps's depencies and compilation
is a broken user hostile model. The potential rabbit hole of versions
incompatibilities and mismatches is a time sink that cannot be justified.

Go is by far the simplest hassle free deploy followed by PHP and Python. For a
unix command line tool that seeks a userbase beyond Ruby users Go or Python
would be the most user friendly choice.

~~~
pmurach
Many systems come preinstalled with Ruby. Bundler is a very elegant and simple
solution - I don't think it is hostile. Quite often the tools that we build
are written by developers for developers or system administrators. For example
Puppet or Chef. In my experience, these are people how don't mind running
couple commands to get started. If anything I have heard people say really
positive things on how easy and pain free installation is. Of course, if you
want to write portable code that works on any system then Go is a very wise
solution.

------
MrBra
Ok neat, but Ruby needs a serious and modern GUI toolkit!

