1
# Copyright (C) 2004, 2005 Aaron Bentley
2
# <aaron.bentley@utoronto.ca>
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 2 of the License, or
7
# (at your option) any later version.
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
# GNU General Public License for more details.
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23
from bzrlib.errors import BzrError
24
from bzrlib.commands import get_cmd_object
1
26
class PromptCmd(cmd.Cmd):
3
28
cmd.Cmd.__init__(self)
6
31
self.tree = arch.tree_root(".")
11
self.fake_aba = abacmds.AbaCmds()
12
36
self.identchars += '-'
13
self.history_file = os.path.expanduser("~/.fai-history")
37
self.history_file = os.path.expanduser("~/.bazaar/shell-history")
14
38
readline.set_completer_delims(string.whitespace)
15
39
if os.access(self.history_file, os.R_OK) and \
16
40
os.path.isfile(self.history_file):
84
108
def default(self, line):
85
109
args = line.split()
86
if find_command(args[0]):
88
find_command(args[0]).do_command(args[1:])
89
except cmdutil.BadCommandOption, e:
91
except cmdutil.GetHelp, e:
92
find_command(args[0]).help()
93
except CommandFailed, e:
95
except arch.errors.ArchiveNotRegistered, e:
97
except KeyboardInterrupt, e:
99
except arch.util.ExecProblem, e:
100
print e.proc.error.rstrip('\n')
101
except cmdutil.CantDetermineVersion, e:
103
except cmdutil.CantDetermineRevision, e:
106
print "Unhandled error:\n%s" % errors.exception_str(e)
108
elif suggestions.has_key(args[0]):
109
print suggestions[args[0]]
111
elif self.fake_aba.is_command(args[0]):
114
tree = arch.tree_root(".")
115
except arch.errors.TreeRootError:
117
cmd = self.fake_aba.is_command(args[0])
119
args = cmdutil.expand_prefix_alias(args[1:], tree)
125
except KeyboardInterrupt, e:
128
elif options.tla_fallthrough and args[0] != "rm" and \
129
cmdutil.is_tla_command(args[0]):
133
tree = arch.tree_root(".")
134
except arch.errors.TreeRootError:
137
args = cmdutil.expand_prefix_alias(args, tree)
141
arch.util.exec_safe('tla', args, stderr=sys.stderr,
142
stdout=sys.stdout, expected=(0, 1))
143
except arch.util.ExecProblem, e:
145
except KeyboardInterrupt, e:
150
tree = arch.tree_root(".")
151
except arch.errors.TreeRootError:
155
args = cmdutil.expand_prefix_alias(args, tree)
159
os.system(" ".join(args))
160
except KeyboardInterrupt, e:
110
commandname = args.pop(0)
112
cmd_obj = get_cmd_object(commandname)
114
return os.system(line)
118
return (cmd_obj.run_argv(args) or 0)
121
except KeyboardInterrupt, e:
124
# print "Unhandled error:\n%s" % errors.exception_str(e)
125
print "Unhandled error:\n%s" % (e)
163
128
def completenames(self, text, line, begidx, endidx):