Class: SkillBench::CLI

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

Overview

Thin CLI dispatcher that routes subcommands to their handlers.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ CLI

Returns a new instance of CLI.

Parameters:

  • argv (Array<String>)

    Raw CLI arguments.



25
26
27
# File 'lib/skill_bench/cli.rb', line 25

def initialize(argv)
  @argv = argv
end

Class Method Details

.call(argv) ⇒ Integer

Entry point called from bin/skill-bench.

Parameters:

  • argv (Array<String>)

    Raw CLI arguments.

Returns:

  • (Integer)

    Exit code.



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

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

Instance Method Details

#callInteger

Dispatches to the appropriate subcommand handler.

Returns:

  • (Integer)

    Exit code.



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/skill_bench/cli.rb', line 32

def call
  help = -> { Cli::HelpPrinter.call }
  return help.call if @argv.empty?

  subcommand = @argv.shift
  case subcommand
  when 'init'  then Cli::InitCommand.call(@argv)
  when 'run'   then Cli::RunCommand.call(@argv)
  when 'skill' then Cli::SkillCommand.call(@argv)
  when 'eval'  then Cli::EvalCommand.call(@argv)
  when '-h', '--help', 'help'
    help.call
  else
    warn "Unknown subcommand: #{subcommand}"
    warn "Run 'skill-bench help' for usage."
    1
  end
end