Class: WifiWand::Platforms::Mac::Helper::SetupCli
- Inherits:
-
Object
- Object
- WifiWand::Platforms::Mac::Helper::SetupCli
- Defined in:
- lib/wifi_wand/platforms/mac/helper/setup_cli.rb
Defined Under Namespace
Classes: LocationSettingsOpenError
Constant Summary collapse
- STEP_LABELS =
{ install_helper: 'Install wifiwand-helper', reinstall_helper: 'Reinstall wifiwand-helper (invalid installation detected)', grant_permission: 'Grant location permission in System Settings', }.freeze
- USER_FACING_SETUP_ERROR =
StandardError excludes process-control and VM-level exceptions like Interrupt, SystemExit, and NoMemoryError.
StandardError- USAGE =
'Usage: wifiwand-macos-setup [--reinstall | --remove]'
Instance Method Summary collapse
-
#initialize(argv:, setup: nil, out_stream: $stdout, in_stream: $stdin) ⇒ SetupCli
constructor
A new instance of SetupCli.
-
#run ⇒ Integer
Run the full setup, reinstall, or remove flow.
Constructor Details
#initialize(argv:, setup: nil, out_stream: $stdout, in_stream: $stdin) ⇒ SetupCli
Returns a new instance of SetupCli.
37 38 39 40 41 42 43 |
# File 'lib/wifi_wand/platforms/mac/helper/setup_cli.rb', line 37 def initialize(argv:, setup: nil, out_stream: $stdout, in_stream: $stdin) @argv = argv.dup @out_stream = out_stream @in_stream = in_stream @setup = setup || Setup.new(out_stream: out_stream) @action = nil end |
Instance Method Details
#run ⇒ Integer
Run the full setup, reinstall, or remove flow.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/wifi_wand/platforms/mac/helper/setup_cli.rb', line 48 def run return perform_remove if @action == :remove support_status = @setup.helper_support_status return perform_not_applicable(support_status) if support_status.unsupported? perform_reinstall if @action == :reinstall status = @setup.check_status return 0 if already_complete?(status) print_header print_status_table(status) steps = status.steps_needed print_steps(steps) wait_for_enter execute_steps(steps) 0 rescue Interrupt @out_stream.puts "\nCancelled." 1 rescue USER_FACING_SETUP_ERROR => e # This is the executable boundary: setup failures should become a clear # message and non-zero exit status instead of a Ruby backtrace. @out_stream.puts "\n❌ Error: #{e.}" 1 end |