Module: Fuelcell::Action::Subcommands

Extended by:
Forwardable
Included in:
Command
Defined in:
lib/fuelcell/action/subcommands.rb

Instance Method Summary collapse

Instance Method Details

#[](name) ⇒ Object



13
14
15
16
# File 'lib/fuelcell/action/subcommands.rb', line 13

def [](name)
  list = name.split(' ')
  deep_find(self, list)
end

#add(cmds) ⇒ Object Also known as: <<



7
8
9
10
# File 'lib/fuelcell/action/subcommands.rb', line 7

def add(cmds)
  cmds = [cmds] unless cmds.is_a?(Array)
  cmds.each { |cmd|  subcommands[cmd.name] = cmd }
end

#exist?(name) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
21
22
# File 'lib/fuelcell/action/subcommands.rb', line 18

def exist?(name)
  list   = name.split(' ')
  result = deep_find(self, list)
  result.is_a?(NotFound) ? false : true
end

#global_options(target) ⇒ Hash

Collect global options from the option manager of every command in the Hierarchy

Returns:

  • (Hash)


36
37
38
# File 'lib/fuelcell/action/subcommands.rb', line 36

def global_options(target)
  collect_global_options(target, self, {})
end

#search(names) ⇒ Fuelcell::Command

Finds a subcommand by name.

Parameters:

  • names (Array)

    hierarchical order of commands

Returns:

  • (Fuelcell::Command)

    of nil when not found



28
29
30
# File 'lib/fuelcell/action/subcommands.rb', line 28

def search(names)
  deep_find(self, names)
end