Class: Roast::CLI
- Inherits:
-
Object
- Object
- Roast::CLI
- Includes:
- Commands
- Defined in:
- lib/roast/cli.rb,
lib/roast/cli/commands.rb
Defined Under Namespace
Modules: Commands
Constant Summary collapse
- BANNER =
<<-BANNER Usage: roast COMMAND [ARGS] Description: The roast command manages groups/entries in your /etc/hosts file. It has a few different commands available: list list the entries in the hosts file alias: l add adds a new entry to the hosts file alias: a enable enables a disabled (commented out) entry alias: e enable-group enables an entire group alias: eg disable disables an entry (comments it out) alias: d disable-group disables an entire group alias: dg delete deletes an entry entirely delete-group deletes an enitre group Examples: # list all entires > roast list # add an entry to the base group > roast add 10.0.1.1 something.dev # add an entry to the "testing" group > roast add testing 127.0.0.1 exampleapp.dev # disable all entries with the ip "10.0.1.1" > roast disable 10.0.1.1 BANNER
Constants included from Commands
Instance Method Summary collapse
-
#parse_options ⇒ Object
Use OptionParser to parse options, then we remove them from ARGV.
- #print_usage_and_exit! ⇒ Object
-
#run ⇒ Object
Called from the executable.
Methods included from Commands
#add, #confirm, #delete, #delete_group, #disable, #disable_group, #dispatch, #enable, #enable_group, #list
Instance Method Details
#parse_options ⇒ Object
Use OptionParser to parse options, then we remove them from ARGV
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/roast/cli.rb', line 36 def @opts = OptionParser.new do |opts| opts. = BANNER.gsub(/^ {4}/, '') opts.separator '' opts.separator 'Options:' opts.on('-v', 'Print the version') do puts Roast::VERSION exit end opts.on( '-h', '--help', 'Display this help.' ) do puts opts exit end end @opts.parse! end |
#print_usage_and_exit! ⇒ Object
57 58 59 60 |
# File 'lib/roast/cli.rb', line 57 def print_usage_and_exit! puts @opts exit end |
#run ⇒ Object
Called from the executable. Parses the command line arguments
63 64 65 66 67 |
# File 'lib/roast/cli.rb', line 63 def run print_usage_and_exit! if ARGV.empty? dispatch end |