Module: Pik::Commands

Defined in:
lib/pik/commands.rb

Class Method Summary collapse

Class Method Details

.add(command) ⇒ Object



9
10
11
# File 'lib/pik/commands.rb', line 9

def self.add(command)
  commands << command
end

.clearObject



5
6
7
# File 'lib/pik/commands.rb', line 5

def self.clear
  commands.clear
end

.commandsObject



28
29
30
# File 'lib/pik/commands.rb', line 28

def self.commands
  @commands ||= []
end

.descriptionObject



21
22
23
24
25
26
# File 'lib/pik/commands.rb', line 21

def self.description
  commands.sort_by{|c| c.name }.map do |cmd|
    "  %-15s %s" % [cmd.names.join('|'), cmd.summary]
  end.join("\n") + 
  "\n\nFor help on a particular command, use 'pik help COMMAND'."
end

.find(command) ⇒ Object



13
14
15
# File 'lib/pik/commands.rb', line 13

def self.find(command)
  commands.find{ |cmd| cmd.names.include?(command.to_sym) }
end

.listObject



17
18
19
# File 'lib/pik/commands.rb', line 17

def self.list
  commands.map{|c| c.names }.flatten
end