Class: ZergXcode::Plugins::Help

Inherits:
Object
  • Object
show all
Defined in:
lib/zerg_xcode/plugins/help.rb

Overview

Displays the help strings for other plugins.

Instance Method Summary collapse

Instance Method Details

#helpObject



13
14
15
16
17
18
19
20
21
# File 'lib/zerg_xcode/plugins/help.rb', line 13

def help
  {:short => 'command-line usage instructions',
   :long => <<"END" }
Usage: help [command]

Shows the usage for the given command. If no command is  given, shows a list of
commands with a short description for each command.
END
end

#run(args) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/zerg_xcode/plugins/help.rb', line 23

def run(args)
  helpstr = "Xcode Project Modifier brought to you by Zergling.Net.\n"

  plugin = args.shift
  if ZergXcode::Plugins.all.include? plugin
    help = ZergXcode::Plugins.get(plugin).help
    helpstr << "#{plugin} - #{help[:short]}\n#{help[:long]}"
  else
    helpstr << "Available commands:\n"
    ZergXcode::Plugins.all.each do |plugin|
      short_help = ZergXcode::Plugins.get(plugin).help[:short]
      helpstr << "  #{plugin}: #{short_help}\n"
    end
  end
  
  print helpstr
  helpstr
end