Class: Chimps::CLI::Runner

Inherits:
Object show all
Includes:
Chimps::Commands
Defined in:
lib/chimps/cli.rb

Overview

Defines methods to parse the original ARGV and from it choose and instantiate the appropriate Chimps::Command subclass with the appropriate arguments.

Constant Summary

Constants included from Chimps::Commands

Chimps::Commands::NAMES

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Chimps::Commands

#command_name?, #construct, construct

Constructor Details

#initialize(argv) ⇒ Chimps::CLI::Runner

Create a new Chimps::CLI::Runner from argv.

Parameters:



39
40
41
# File 'lib/chimps/cli.rb', line 39

def initialize argv
  @argv = argv
end

Instance Attribute Details

#argvObject (readonly)

The original ARGV passed in by the user.



33
34
35
# File 'lib/chimps/cli.rb', line 33

def argv
  @argv
end

Instance Method Details

#commandChimps::Command

The chosen and initialized command for this Runner.

Returns:



51
52
53
# File 'lib/chimps/cli.rb', line 51

def command
  @command ||= construct(command_name, argv_for_command)
end

#execute!Object

Execute this Runner’s chosen and initialized command.



44
45
46
# File 'lib/chimps/cli.rb', line 44

def execute!
  command.execute!
end