1 # Copyright (C) 2006-2009 Aaron Bentley and Panometrics, Inc.
2 # Gianluca Montecchi <gian@grys.it>
3 # Thomas Gerigk <tgerigk@gmx.de>
4 # 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 along
17 # with this program; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 """Print help for given subcommand"""
20 from libbe import cmdutil, utility
23 def execute(args, manipulate_encodings=True, restrict_file_access=False,
26 Print help of specified command (the manipulate_encodings argument
30 Usage: be help [COMMAND]
33 -h, --help Print a help message
34 --complete Print a list of available completions
36 Print help for specified command or list of all commands.
40 options, args = parser.parse_args(args)
41 complete(options, args, parser)
43 raise cmdutil.UsageError("Too many arguments.")
48 print cmdutil.help(args[0])
49 except AttributeError:
50 print "No help available"
53 parser = cmdutil.CmdOptionParser("be help [COMMAND]")
57 Print help for specified command or list of all commands.
61 return get_parser().help_str() + longhelp
63 def complete(options, args, parser):
64 for option, value in cmdutil.option_value_pairs(options, parser):
65 if value == "--complete":
66 # no argument-options at the moment, so this is future-proofing
67 raise cmdutil.GetCompletions()
68 if "--complete" in args:
69 cmds = [command for command,module in cmdutil.iter_commands()]
70 raise cmdutil.GetCompletions(cmds)