Class: Juicer::Cli
- Inherits:
-
Object
- Object
- Juicer::Cli
- Defined in:
- lib/juicer/cli.rb
Class Method Summary collapse
-
.run(arguments = ARGV) ⇒ Object
Run CLI.
Instance Method Summary collapse
-
#initialize ⇒ Cli
constructor
A new instance of Cli.
-
#parse(arguments = ARGV) ⇒ Object
Set up command parser and parse arguments.
Constructor Details
Class Method Details
.run(arguments = ARGV) ⇒ Object
Run CLI
35 36 37 38 |
# File 'lib/juicer/cli.rb', line 35 def self.run(arguments = ARGV) juicer = self.new juicer.parse(arguments) end |
Instance Method Details
#parse(arguments = ARGV) ⇒ Object
Set up command parser and parse arguments
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/juicer/cli.rb', line 15 def parse(arguments = ARGV) @cmd = CmdParse::CommandParser.new(true, true) @cmd.program_name = "juicer" @cmd.program_version = Juicer.version.split(".") @cmd. = CmdParse::OptionParserWrapper.new do |opt| opt.separator "Global options:" opt.on("-v", "--verbose", "Be verbose when outputting info") { |t| @log.level = Logger::DEBUG } opt.on("-q", "--quiet", "Only log warnings and errors") { |t| @log.level = Logger::WARN } end add_commands @cmd.parse(arguments) @log.close rescue SystemExit exit end |