CommandLineHelper
This helps other gems with their common CLI chores.
At the moment, it generates a nice help output based on options_possible
defined in the
class that includes CommandLineHelper::HelpText
.
Installation
Add this line to your application's Gemfile:
gem 'command_line_helper'
And then execute:
$ bundle
Or install it yourself as:
$ gem install command_line_helper
Usage
require 'command_line_helper'
class CLI
include CommandLineHelper::HelpText
def do_something
puts help_info
end
private
def
[
['--foo', '-f', GetoptLong::REQUIRED_ARGUMENT, "This option foo takes an argument"],
['--bar', '-f', GetoptLong::NO_ARGUMENT, "This option bar does not take an argument"]
]
end
def version_info
"This is version BLAH of this amazing package. (c) Someone Somewhere Today."
end
end
CLI.new.do_something
$ ruby ./cli.rb
Usage: cli.rb [options]
[--foo|-f argument], [--bar|-f]
Options:
--foo, -f This option foo takes an argument
--bar, -f This option bar does not take an argument
This is version BLAH of this amazing package. (c) Someone Somewhere Today.
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request