Class: SkillBench::Services::OptionParserService Deprecated

Inherits:
Object
  • Object
show all
Defined in:
lib/skill_bench/services/option_parser_service.rb

Overview

Deprecated.

Use Cli::RunCommand option parsing instead.

Parses CLI arguments for the EvaluateCommand using Ruby’s OptionParser. Provides standardized error handling for invalid flags and missing arguments.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ OptionParserService

Returns a new instance of OptionParserService.

Parameters:

  • argv (Array<String>)

    Raw CLI arguments.



20
21
22
# File 'lib/skill_bench/services/option_parser_service.rb', line 20

def initialize(argv)
  @argv = argv
end

Class Method Details

.call(argv) ⇒ Hash

Parses command-line options into a hash.

Parameters:

  • argv (Array<String>)

    Raw CLI arguments.

Returns:

  • (Hash)

    Result envelope with parsed options or error message.



15
16
17
# File 'lib/skill_bench/services/option_parser_service.rb', line 15

def self.call(argv)
  new(argv).call
end

Instance Method Details

#callHash

Parses the arguments and returns a result hash.

Returns:

  • (Hash)

    Result envelope with parsed options or error message.



27
28
29
30
31
32
33
34
35
# File 'lib/skill_bench/services/option_parser_service.rb', line 27

def call
  options = {}

  parser(options).parse!(@argv)

  { success: true, response: options }
rescue OptionParser::ParseError => e
  { success: false, response: { error: { message: e.message } } }
end