Class: CLIForge::CommandSet

Inherits:
Object
  • Object
show all
Defined in:
lib/cli_forge/command_set.rb

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ CommandSet

Returns a new instance of CommandSet.



3
4
5
# File 'lib/cli_forge/command_set.rb', line 3

def initialize(config)
  @config = config
end

Instance Method Details

#[](command_name) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/cli_forge/command_set.rb', line 7

def [](command_name)
  if embedded_command = @config.embedded_commands[command_name.to_sym]
    return embedded_command
  end

  target_bin = @config.bin_name + @config.bin_separator + command_name.to_s
  commands   = find_bin_commands(target_bin)

  # if commands.size > 1
    # TODO: Warn
  # end

  commands.first
end