This repository has been archived by the owner on Jan 26, 2022. It is now read-only.
forked from vito/mothership
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
receives help group info
- Loading branch information
Alex Suraci and Tim Labeeuw
committed
Nov 28, 2012
1 parent
f688a42
commit 107d9f4
Showing
3 changed files
with
236 additions
and
216 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
require "mothership/help/printer" | ||
|
||
class Mothership | ||
class << self | ||
# add command to help group | ||
def group(*names) | ||
options = | ||
if names.last.is_a? Hash | ||
names.pop | ||
else | ||
{} | ||
end | ||
|
||
Mothership::Help.add_to_group(@command, names, options) | ||
end | ||
end | ||
|
||
def default_action | ||
invoke :help | ||
end | ||
|
||
def unknown_command(name) | ||
$stderr.print "Unknown command '#{name.to_s.gsub("_", "-")}'. " | ||
$stderr.puts "See 'help' for available commands." | ||
exit_status 1 | ||
end | ||
|
||
desc "Help!" | ||
input :command, :argument => :optional | ||
input :all, :type => :boolean | ||
def help | ||
if name = input[:command] | ||
if cmd = @@commands[name.gsub("-", "_").to_sym] | ||
Mothership::Help.command_help(cmd) | ||
else | ||
unknown_command(name) | ||
end | ||
elsif Help.has_groups? | ||
unless input[:all] | ||
puts "Showing basic command set. Pass --all to list all commands." | ||
puts "" | ||
end | ||
|
||
Mothership::Help.print_help_groups(@@global, input[:all]) | ||
else | ||
Mothership::Help.basic_help(@@commands, @@global) | ||
end | ||
end | ||
end | ||
|
||
class Mothership::Command | ||
def group | ||
p Mothership::Help.tree[:apps][:children][:manage] | ||
end | ||
end |
Oops, something went wrong.