2 # Copyright (C) 2005-2009 Aaron Bentley and Panometrics, Inc.
3 # Chris Ball <cjb@laptop.org>
4 # Oleg Romanyshyn <oromanyshyn@panoramicfeedback.com>
5 # W. Trevor King <wking@drexel.edu>
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License along
18 # with this program; if not, write to the Free Software Foundation, Inc.,
19 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 from libbe import cmdutil, _version
26 __doc__ = cmdutil.help()
28 usage = "be [options] [command] [command_options ...] [command_args ...]"
30 parser = cmdutil.CmdOptionParser(usage)
32 parser.add_option("--version", action="store_true", dest="version",
33 help="Print version string and exit.")
34 parser.add_option("-d", "--dir", dest="dir", metavar="DIR",
35 help="Run this command from DIR instead of the current directory.")
38 options,args = parser.parse_args()
39 for option,value in cmdutil.option_value_pairs(options, parser):
40 if value == "--complete":
44 paths = cmdutil.complete_path(args[0])
45 raise cmdutil.GetCompletions(paths)
46 except cmdutil.GetHelp:
47 print cmdutil.help(parser=parser)
49 except cmdutil.GetCompletions, e:
50 print '\n'.join(e.completions)
53 if options.version == True:
54 print _version.version_info["revision_id"]
56 if options.dir != None:
61 raise cmdutil.UsageError, "must supply a command"
62 sys.exit(cmdutil.execute(args[0], args[1:]))
63 except cmdutil.GetHelp:
64 print cmdutil.help(sys.argv[1])
66 except cmdutil.GetCompletions, e:
67 print '\n'.join(e.completions)
69 except cmdutil.UnknownCommand, e:
72 except cmdutil.UsageError, e:
73 print "Invalid usage:", e
75 print cmdutil.help(parser=parser)
78 print cmdutil.help(sys.argv[1])
80 except cmdutil.UserError, e: