236 karma · joined June 22, 2013
GitHub: https://github.com/piotrmurach
[1] http://tldp.org/LDP/abs/html/exitcodes.html [2] https://man.openbsd.org/signal.3
I have included a method that helps you check if a code is reserved or not. For example, TTY::Exit.exit_reserved?(126) will return true as this is a status used by Bash to indicate a problem with executing a command.
* It includes default user-friendly error messages for all the built-in exit codes. For example, the code 64 will print " "ERROR(64): Command line usage error" to stderr.
* Machines, e.i. programs that, for example, watch over an executable can decided based on the error code what to do. If the program is interrupted by Ctrl-C then the parent program can handle the situation gracefully.
I totally agree that an example of using an exit code in a parent program would be beneficial.
In my scripting experience I tend to gravitate towards two solutions. If my script is fairly small, e.i. in a single file, with no much complexity I tend to use Ruby standard library optparse. However, if my needs get a bit more complex and I need, for example, subcommands I use thor. Thor gives me a better way to structure my application logic. These two solutions so far have covered all my needs.
Other solutions that I've played in the past are:
* main - very sweet DSL (https://github.com/ahoward/main)
* clamp - (https://github.com/mdub/clamp)
* slop - (https://github.com/leejarvis/slop)
* gli - for Git-like interfaces (https://github.com/davetron5000/gli)
My recommendation before using other libraries would be to really give optparse a good spin so that you can figure out why the other options are more suitable.
There is still plenty of scripts that I write that are geared towards development workflow. I haven't had issues on setting up these tools on Debian servers, Ruby is usually preinstalled and all you need is bundler to get what you need.
Few people pointed out the broken website to me, I'll definitely fix. I
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.
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!
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.