Class: Bparity::CLI
- Inherits:
-
Object
- Object
- Bparity::CLI
- Includes:
- FormalCommands, VerificationCommands
- Defined in:
- lib/bparity/cli.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(out:, err:) ⇒ CLI
constructor
A new instance of CLI.
- #start(argv) ⇒ Object
Constructor Details
#initialize(out:, err:) ⇒ CLI
Returns a new instance of CLI.
16 17 18 19 |
# File 'lib/bparity/cli.rb', line 16 def initialize(out:, err:) @out = out @err = err end |
Class Method Details
.start(argv = ARGV, out: $stdout, err: $stderr) ⇒ Object
12 13 14 |
# File 'lib/bparity/cli.rb', line 12 def self.start(argv = ARGV, out: $stdout, err: $stderr) new(out:, err:).start(argv) end |
Instance Method Details
#start(argv) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/bparity/cli.rb', line 21 def start(argv) command = argv.shift return help if command.nil? || %w[-h --help help].include?(command) send("command_#{command.tr('-', '_')}", argv) rescue OptionParser::ParseError, Error => e @err.puts("Error: #{e.}") 2 rescue LoadError, SystemCallError => e @err.puts("Error: #{e.}. Check the path and permissions, then try again.") 2 rescue KeyError => e @err.puts("Error: missing configuration entry #{e.key.inspect}. Regenerate the bundle or update the adapter.") 2 rescue NoMethodError => e raise unless e.name.to_s.start_with?("command_") @err.puts("Error: unknown command #{command.inspect}. Run `bparity help` for usage.") 2 end |