Class: WifiWand::Main
- Inherits:
-
Object
- Object
- WifiWand::Main
- Defined in:
- lib/wifi_wand/main.rb
Constant Summary collapse
- SUCCESS_EXIT_CODE =
0- FAILURE_EXIT_CODE =
1- INTERRUPT_EXIT_CODE =
130- CLI_BOUNDARY_ERROR =
StandardError excludes process-control and VM-level exceptions like Interrupt, SystemExit, and NoMemoryError.
StandardError
Instance Method Summary collapse
- #call(argv = @argv) ⇒ Object
-
#initialize(out_stream = $stdout, err_stream = $stderr, argv: ARGV, env: ENV, in_stream: $stdin) ⇒ Main
constructor
A new instance of Main.
Constructor Details
#initialize(out_stream = $stdout, err_stream = $stderr, argv: ARGV, env: ENV, in_stream: $stdin) ⇒ Main
Returns a new instance of Main.
21 22 23 24 25 26 27 |
# File 'lib/wifi_wand/main.rb', line 21 def initialize(out_stream = $stdout, err_stream = $stderr, argv: ARGV, env: ENV, in_stream: $stdin) @out_stream = out_stream @err_stream = err_stream @in_stream = in_stream @argv = argv @env = env end |
Instance Method Details
#call(argv = @argv) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/wifi_wand/main.rb', line 29 def call(argv = @argv) = CommandLineParser.new(argv, @env, @err_stream).parse if .version_requested @out_stream.puts(WifiWand::VERSION) return SUCCESS_EXIT_CODE end # Ensure CLI and model share the main's output streams .out_stream = @out_stream .err_stream = @err_stream .in_stream = @in_stream WifiWand::CommandLineInterface.new(, argv: .argv).call rescue Interrupt => e handle_interrupt(e, ) INTERRUPT_EXIT_CODE rescue CLI_BOUNDARY_ERROR => e # For option parsing errors, we don't have options.verbose yet, so default to false verbose = !!&.verbose handle_error(e, verbose) FAILURE_EXIT_CODE end |