1 # Copyright (C) 2006-2009 Aaron Bentley and Panometrics, Inc.
2 # Thomas Gerigk <tgerigk@gmx.de>
3 # W. Trevor King <wking@drexel.edu>
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 """Print help for given subcommand"""
20 from libbe import cmdutil, utility
25 Print help of specified command.
27 Usage: be help [COMMAND]
30 -h, --help Print a help message
31 --complete Print a list of available completions
33 Print help for specified command or list of all commands.
37 options, args = parser.parse_args(args)
38 complete(options, args, parser)
40 raise cmdutil.UsageError("Too many arguments.")
45 print cmdutil.help(args[0])
46 except AttributeError:
47 print "No help available"
50 parser = cmdutil.CmdOptionParser("be help [COMMAND]")
54 Print help for specified command or list of all commands.
58 return get_parser().help_str() + longhelp
60 def complete(options, args, parser):
61 for option, value in cmdutil.option_value_pairs(options, parser):
62 if value == "--complete":
63 # no argument-options at the moment, so this is future-proofing
64 raise cmdutil.GetCompletions()
65 if "--complete" in args:
66 cmds = [command for command,module in cmdutil.iter_commands()]
67 raise cmdutil.GetCompletions(cmds)