Class: Opsup::CLI
- Inherits:
-
Object
- Object
- Opsup::CLI
- Extended by:
- T::Sig
- Defined in:
- lib/opsup/cli.rb,
lib/opsup/cli/option_builder.rb
Defined Under Namespace
Classes: OptionBuilder
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(app:, option_builder:, env_vars:) ⇒ CLI
constructor
A new instance of CLI.
- #run(argv) ⇒ Object
Constructor Details
#initialize(app:, option_builder:, env_vars:) ⇒ CLI
Returns a new instance of CLI.
27 28 29 30 31 |
# File 'lib/opsup/cli.rb', line 27 def initialize(app:, option_builder:, env_vars:) @app = T.let(app, Opsup::App) @option_builder = T.let(option_builder, Opsup::CLI::OptionBuilder) @env_vars = T.let(env_vars, T::Hash[String, T.nilable(String)]) end |
Class Method Details
Instance Method Details
#run(argv) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/opsup/cli.rb', line 34 def run(argv) parser = create_parser @option_builder.(parser) = @option_builder.(@env_vars) 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.}" return false end true end |