Class: Agent::SessionContext::CLI::Options
- Inherits:
-
Object
- Object
- Agent::SessionContext::CLI::Options
- Defined in:
- lib/agent/session_context/cli/options.rb
Class Method Summary collapse
- .hinted_format(arguments) ⇒ Object
- .parse(arguments, command:) ⇒ Object
- .parse_no_args(arguments, command:) ⇒ Object
Class Method Details
.hinted_format(arguments) ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/agent/session_context/cli/options.rb', line 89 def hinted_format(arguments) limit = arguments.index("--") || arguments.length effective = :text index = 0 while index < limit token = arguments[index] if token == "--format" candidate = arguments[index + 1] effective = candidate.to_sym if CLI::FORMATS.include?(candidate) index += 2 next end if token.start_with?("--format=") candidate = token.split("=", 2).last effective = candidate.to_sym if CLI::FORMATS.include?(candidate) end index += 1 end effective end |
.parse(arguments, command:) ⇒ Object
78 79 80 81 82 83 84 85 86 87 |
# File 'lib/agent/session_context/cli/options.rb', line 78 def parse(arguments, command:) descriptor = command_descriptor(command) = validate_argument_encoding!(arguments) (arguments, descriptor:) remaining = parser(, descriptor:).permute(arguments.dup) validate_selection!(, remaining, command:, descriptor:) .merge(identifier: remaining.first).freeze end |
.parse_no_args(arguments, command:) ⇒ Object
115 116 117 118 119 120 121 |
# File 'lib/agent/session_context/cli/options.rb', line 115 def parse_no_args(arguments, command:) descriptor = command_descriptor(command) validate_argument_encoding!(arguments) (arguments, descriptor:) remaining = OptionParser.new.permute(arguments.dup) raise OptionParser::ParseError, "unexpected arguments: #{remaining.join(" ")}" unless remaining.empty? end |