| Class | Dctl::CommandLineParser |
| In: |
lib/dctl/cmdparser.rb
|
| Parent: | Object |
This class is used to parse user command line.
# File lib/dctl/cmdparser.rb, line 16
16: def self.parse!(program_name, argv)
17: cmd_parser = CommandParser.new
18:
19: cmd_parser.options { |opt|
20: opt.program_name = program_name
21: opt.version = Dctl::VERSION
22: opt.release = Dctl::RELEASE
23: opt.separator 'args contains target program to daemonize and its arguments.'
24: opt.separator ''
25: opt.separator 'Global options:'
26: opt.on('-d', '--dir DIR', "Path where to store pidfiles (default is '#{$DIR}')") { |$DIR| }
27: }
28:
29: cmd_parser.add_command Dctl::Command::StartCommand.new
30: cmd_parser.add_command Dctl::Command::StopCommand.new
31: cmd_parser.add_command Dctl::Command::RunCommand.new
32: cmd_parser.add_command Dctl::Command::RestartCommand.new
33: cmd_parser.add_command Dctl::Command::ZapCommand.new
34: cmd_parser.add_command Dctl::Command::StatusCommand.new, true
35: cmd_parser.add_command CommandParser::HelpCommand.new
36: cmd_parser.add_command CommandParser::VersionCommand.new
37:
38: cmd_parser.parse! argv
39: end