I’m creating a gem in which I would like to be able to make a shell command performing a function in the gem. In a more simple context, I need to create a shell script that performs a Ruby function with options when the shell command is triggered. What is a easiest way to do this?
For example:
$ cow moo
would take a cow gem with a script for the cow command and perform the ‘moo’ function in the Ruby gem.
If I could, I would also like support for common ‘options’ formatting in the shell:
$ cow -t moo
Which the above example would take an option and apply a script in Ruby to handle it (in this example -t would print ‘moo’ twice).
If anyone could help we with this it would be a great help. Thanks!
How about using http://visionmedia.github.com/commander/? Never used it before. But it’s a gem that makes developing commandline apps easier 🙂 Does the heavy lifting for you.
There is a bunch more over here: https://www.ruby-toolbox.com/categories/CLI_Option_Parsers