Class: Rpremote::CLI
- Inherits:
-
Object
- Object
- Rpremote::CLI
- Defined in:
- lib/rpremote/cli.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(stdout: $stdout, stderr: $stderr, serial: Serial, device: Device, flasher: Flasher) ⇒ CLI
constructor
A new instance of CLI.
- #run(argv, config: Config) ⇒ Object
Constructor Details
#initialize(stdout: $stdout, stderr: $stderr, serial: Serial, device: Device, flasher: Flasher) ⇒ CLI
Returns a new instance of CLI.
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/rpremote/cli.rb', line 21 def initialize( stdout: $stdout, stderr: $stderr, serial: Serial, device: Device, flasher: Flasher ) @stdout = stdout @stderr = stderr @serial = serial @device = device @flasher = flasher end |
Class Method Details
.start(argv = ARGV, config: Config, **options) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/rpremote/cli.rb', line 14 def self.start(argv = ARGV, config: Config, **) new(**).run(argv, config: config) rescue OptionParser::ParseError, ArgumentError, SystemCallError, Rpremote::Error => e .fetch(:stderr, $stderr).puts("rpremote: #{e.}") 1 end |
Instance Method Details
#run(argv, config: Config) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/rpremote/cli.rb', line 35 def run(argv, config: Config) args = argv.dup @config_class = config @config_filename, config_required = config.extract_option!(args) command = args.shift return show_help(command, args) if Help.requested?(command, args) @config_options = config.load_command(command, filename: config_filename, required: config_required) dispatch(command, args) 0 end |