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



30
31
32
# File 'lib/pik/commands.rb', line 30

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

.deprecate(command) ⇒ Object



34
35
36
# File 'lib/pik/commands.rb', line 34

def self.deprecate(command)
  deprecated.update command
end

.deprecatedObject



38
39
40
# File 'lib/pik/commands.rb', line 38

def self.deprecated
  @deprecated ||= {}
end

.descriptionObject



23
24
25
26
27
28
# File 'lib/pik/commands.rb', line 23

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
16
17
# File 'lib/pik/commands.rb', line 13

def self.find(command)
  command = command.to_sym
  puts deprecated[command] if deprecated[command]
  commands.find{ |cmd| cmd.names.include?(command) }
end

.listObject



19
20
21
# File 'lib/pik/commands.rb', line 19

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