Class: WifiWand::Commands::Qr
Constant Summary
Constants inherited from Base
Base::DEFAULT_INVOCATION_OPTIONS
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #call(*args) ⇒ Object
- #help_text ⇒ Object
- #validate_options(invocation_options:, command_options:, args:, context: nil) ⇒ Object
Methods inherited from Base
#aliases, allow_invocation_options, allowed_invocation_options, #bind, binding_sources, binds, command_metadata, declared_metadata, #initialize
Constructor Details
This class inherits a constructor from WifiWand::Commands::Base
Instance Method Details
#call(*args) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/wifi_wand/commands/qr.rb', line 32 def call(*args) validate_max_arguments!(args, 2) filespec, password = args if stdout_target?(filespec) validate_stdout_output_format! model.print_qr_code(password: password) interactive_mode ? silent_result : nil else result = model.generate_qr_code(filespec, password: password, in_stream: in_stream) output_support.handle_output(result, -> { "QR code generated: #{result}" }) end end |
#help_text ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/wifi_wand/commands/qr.rb', line 18 def help_text <<~HELP #{.usage} #{.description} Default output prints an ANSI QR to stdout Pass a filename to write a QR image file Use a hyphen explicitly for stdout when passing a password Supported file extensions are .png, .svg, and .eps Optional password avoids the macOS auth prompt HELP end |
#validate_options(invocation_options:, command_options:, args:, context: nil) ⇒ Object
47 48 49 50 51 52 53 54 |
# File 'lib/wifi_wand/commands/qr.rb', line 47 def (invocation_options:, command_options:, args:, context: nil) errors = super return errors unless stdout_target?(args.first) return errors unless Array(.).include?(:output_format) return errors if output_format_source() == :environment errors + [stdout_output_format_error] end |