Class: SidekiqVigil::CLI
- Inherits:
-
Object
- Object
- SidekiqVigil::CLI
- Defined in:
- lib/sidekiq_vigil/cli.rb
Constant Summary collapse
- EXIT_OK =
0- EXIT_ALERT =
2- EXIT_UNAVAILABLE =
3
Instance Method Summary collapse
-
#initialize(config: SidekiqVigil.config, storage: nil, out: $stdout, err: $stderr, checker_factory: nil) ⇒ CLI
constructor
A new instance of CLI.
- #run(arguments) ⇒ Object
Constructor Details
#initialize(config: SidekiqVigil.config, storage: nil, out: $stdout, err: $stderr, checker_factory: nil) ⇒ CLI
Returns a new instance of CLI.
12 13 14 15 16 17 18 |
# File 'lib/sidekiq_vigil/cli.rb', line 12 def initialize(config: SidekiqVigil.config, storage: nil, out: $stdout, err: $stderr, checker_factory: nil) @config = config @resolved_storage = storage @out = out @err = err @checker_factory = checker_factory || -> { Checker.new(storage: resolved_storage, config:) } end |
Instance Method Details
#run(arguments) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/sidekiq_vigil/cli.rb', line 20 def run(arguments) args = arguments.dup load_config(extract_config_path(args)) configure_sidekiq_api command = args.shift || "run" handler = command_handlers(args)[command] return unknown_command(command) unless handler handler.call rescue OptionParser::ParseError, ConfigError, ArgumentError => e err.puts(e.) EXIT_UNAVAILABLE end |