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