Skip to content

Commit b2b5b91

Browse files
committed
Incorporate review feedback
1 parent dba586b commit b2b5b91

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

awsshell/app.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,19 @@ def _get_editor_command(self):
6161
else:
6262
return compat.default_editor()
6363

64-
def run(self, command, context):
64+
def run(self, command, application):
65+
"""Open application's history buffer in an editor.
66+
67+
:type command: list
68+
:param command: The dot command as a list split
69+
on whitespace, e.g ``['.foo', 'arg1', 'arg2']``
70+
71+
:type application: AWSShell
72+
:param application: The application object.
73+
74+
"""
6575
all_commands = '\n'.join(
66-
['aws ' + h for h in list(context.history)
76+
['aws ' + h for h in list(application.history)
6777
if not h.startswith(('.', '!'))])
6878
with tempfile.NamedTemporaryFile('w') as f:
6979
f.write(all_commands)
@@ -82,27 +92,27 @@ def __init__(self, output=sys.stdout, err=sys.stderr):
8292
self._output = output
8393
self._err = err
8494

85-
def handle_cmd(self, command, context):
95+
def handle_cmd(self, command, application):
8696
"""Handles running a given dot command from a user.
8797
8898
:type command: str
8999
:param command: The full dot command string, e.g. ``.edit``,
90100
of ``.profile prod``.
91101
92-
:type context: AWSShell
93-
:param context: The application object.
102+
:type application: AWSShell
103+
:param application: The application object.
94104
95105
"""
96106
parts = command.split()
97107
cmd_name = parts[0][1:]
98108
if cmd_name not in self.HANDLER_CLASSES:
99-
self._unknown_cmd(parts, context)
109+
self._unknown_cmd(parts, application)
100110
else:
101111
# Note we expect the class to support no-arg
102112
# instantiation.
103-
self.HANDLER_CLASSES[cmd_name]().run(parts, context)
113+
self.HANDLER_CLASSES[cmd_name]().run(parts, application)
104114

105-
def _unknown_cmd(self, cmd_parts, context):
115+
def _unknown_cmd(self, cmd_parts, application):
106116
self._err.write("Unknown dot command: %s\n" % cmd_parts[0])
107117

108118

@@ -200,7 +210,7 @@ def run(self):
200210
if text.startswith('.'):
201211
# These are special commands. The only one supported for
202212
# now is .edit.
203-
self._dot_cmd.handle_cmd(text, context=self)
213+
self._dot_cmd.handle_cmd(text, application=self)
204214
else:
205215
if text.startswith('!'):
206216
# Then run the rest as a normally shell command.

0 commit comments

Comments
 (0)