Skip to content

Commit

Permalink
Prompt user on quit.
Browse files Browse the repository at this point in the history
  • Loading branch information
cortesi committed Jan 27, 2011
1 parent 0742bc4 commit 091db9c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
22 changes: 17 additions & 5 deletions libmproxy/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ def edit(self, part):
if not conn.set_url(url):
return "Invalid URL."
elif part == "m" and self.viewing == self.REQ:
self.master.prompt_onekey("Method ", self.methods, self.edit_method)
self.master.prompt_onekey("Method", self.methods, self.edit_method)
key = None
self.master.refresh_connection(self.flow)

Expand Down Expand Up @@ -372,7 +372,7 @@ def keypress(self, size, key):
elif key == "e":
if self.viewing == self.REQ:
self.master.prompt_onekey(
"Edit request ",
"Edit request",
(
("header", "h"),
("body", "b"),
Expand All @@ -383,7 +383,7 @@ def keypress(self, size, key):
)
else:
self.master.prompt_onekey(
"Edit response ",
"Edit response",
(
("header", "h"),
("body", "b"),
Expand Down Expand Up @@ -946,7 +946,7 @@ def prompt_onekey(self, prompt, keys, callback):
Keys are a set of (word, key) tuples. The appropriate key in the
word is highlighted.
"""
prompt = [prompt, "("]
prompt = [prompt, " ("]
mkup = []
for i, e in enumerate(keys):
parts = e[0].split(e[1], 1)
Expand Down Expand Up @@ -1076,7 +1076,15 @@ def loop(self):
if self.nested:
self.view_connlist()
else:
raise Stop
self.prompt_onekey(
"Quit",
(
("yes", "y"),
("no", "n"),
),
self.quit,
)
k = None
elif k == "S":
self.path_prompt("Save flows: ", self.save_flows)
k = None
Expand All @@ -1091,6 +1099,10 @@ def loop(self):
except (Stop, KeyboardInterrupt):
pass

def quit(self, a):
if a != "n":
raise Stop

def shutdown(self):
for i in self.state.flow_list:
i.kill()
Expand Down
5 changes: 1 addition & 4 deletions mitmproxy
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,7 @@ if __name__ == '__main__':
m = console.ConsoleMaster(server, options)

for i in args:
msg = m.load_flows(i)
if msg:
print >> sys.stderr, msg
sys.exit(1)
m.load_flows(i)
m.run()


0 comments on commit 091db9c

Please sign in to comment.