Class: Opsup::CLI
- Inherits:
-
Object
- Object
- Opsup::CLI
- Defined in:
- lib/opsup/cli.rb
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
16 17 18 19 |
# File 'lib/opsup/cli.rb', line 16 def initialize(app:, option_builder:) @app = app @option_builder = option_builder end |
Class Method Details
.create ⇒ Object
9 10 11 12 13 14 |
# File 'lib/opsup/cli.rb', line 9 def self.create new( app: Opsup::App.create, option_builder: Opsup::CLI::OptionBuilder.create, ) end |
Instance Method Details
#run(argv) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/opsup/cli.rb', line 21 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 |