Class: Sekret::CLI::Runner

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

Overview

The class that handle the CLI

Author:

  • Maddie Schipper

Since:

  • 1.0.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Runner

Create a new runner instance

Parameters:

  • args (Array<String>)

    The CLI arguments

Since:

  • 1.0.0



24
25
26
# File 'lib/sekret/cli/runner.rb', line 24

def initialize(args)
  @args = args
end

Instance Attribute Details

#argsArray<String> (readonly)

The arguments left after parsing options

Returns:

  • (Array<String>)

Since:

  • 1.0.0



18
19
20
# File 'lib/sekret/cli/runner.rb', line 18

def args
  @args
end

Instance Method Details

#callObject

Perform the CLI call

Since:

  • 1.0.0



30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/sekret/cli/runner.rb', line 30

def call
  command = args.shift
  case command
  when 'generate-keys'
    perform_generate_keys
  when 'help'
    print_help
  when 'version'
    print_version
  else
    raise "Unknown Command #{command}. Try `sekret help`"
  end
end