Class: Opsup::CLI
Defined Under Namespace
Classes: OptionBuilder
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(app:, option_builder:) ⇒ CLI
constructor
A new instance of CLI.
- #run(argv) ⇒ Object
Constructor Details
#initialize(app:, option_builder:) ⇒ CLI
Returns a new instance of CLI.
19 20 21 22 |
# File 'lib/opsup/cli.rb', line 19 def initialize(app:, option_builder:) @app = T.let(app, Opsup::App) @option_builder = T.let(option_builder, Opsup::CLI::OptionBuilder) end |
Class Method Details
.create ⇒ Object
11 12 13 14 15 16 |
# File 'lib/opsup/cli.rb', line 11 def self.create new( app: Opsup::App.create, option_builder: Opsup::CLI::OptionBuilder.create, ) end |
Instance Method Details
#run(argv) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/opsup/cli.rb', line 25 def run(argv) parser = create_parser @option_builder.(parser) = {} begin # It automatically exits with a help message if necessary. commands = parser.parse(argv, into: ) rescue OptionParser::MissingArgument => e puts e. return false end begin config = @option_builder.generate_config() @app.run(commands, config) rescue Opsup::Error => e puts "Error: #{e.message}" return false end true end |