Class: EchSpec::CLI::Run
- Inherits:
-
Object
- Object
- EchSpec::CLI::Run
- Defined in:
- lib/echspec/cli/run.rb
Instance Method Summary collapse
- #execute(argv) ⇒ Object
-
#parse_options(argv) ⇒ Object
rubocop: disable Metrics/AbcSize rubocop: disable Metrics/MethodLength.
Instance Method Details
#execute(argv) ⇒ Object
4 5 6 7 8 9 10 11 12 |
# File 'lib/echspec/cli/run.rb', line 4 def execute(argv) fpath, port, force_compliant, verbose, hostname, sections = (argv) if sections.nil? Spec.run(fpath, port, hostname, force_compliant, verbose) else Spec.run_only(fpath, port, hostname, sections, verbose) end end |
#parse_options(argv) ⇒ Object
rubocop: disable Metrics/AbcSize rubocop: disable Metrics/MethodLength
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 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 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/echspec/cli/run.rb', line 16 def (argv) op = OptionParser.new # default value fpath = nil port = 443 force_compliant = true verbose = false sections = nil op.on( '-f', '--file FILE', 'path to ECHConfigs PEM file (default resolve ECHConfigs via DNS)' ) do |v| fpath = v end op.on( '-p', '--port VALUE', "server port number (default #{port})" ) do |v| port = v end op.on( '-n', '--not-force-compliant-hpke', 'not force compliant ECHConfig HPKE cipher suite' ) do force_compliant = false end op.on( '-v', '--verbose', 'verbose mode; prints message stack if raised an error' ) do verbose = true end op.on( '-s', '--sections SECTIONS', 'sections to test; by the default, test all sections' ) do |v| sections = v.split(',') end op. = 'Usage: echspec run [OPTIONS...] {HOSTNAME}' begin args = op.parse(argv) rescue OptionParser::InvalidOption, OptionParser::MissingArgument => e warn op warn "** #{e.message}" exit 1 end if !fpath.nil? && !File.exist?(fpath) warn '** {FILE} is not found' exit 1 end unknowns = sections.nil? ? [] : sections - Spec.sections unless unknowns.empty? warn "** #{unknowns} are unknown sections" exit 1 end if args.length != 1 warn op warn '** {HOSTNAME} argument is not specified' exit 1 end hostname = args[0] [fpath, port, force_compliant, verbose, hostname, sections] end |