MCPcopy Index your code
hub / github.com/awslabs/aws-shell / DotCommandHandler

Class DotCommandHandler

awsshell/app.py:154–188  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

152
153
154class DotCommandHandler(object):
155 HANDLER_CLASSES = {
156 'edit': EditHandler,
157 'profile': ProfileHandler,
158 'cd': ChangeDirHandler,
159 'exit': ExitHandler,
160 'quit': ExitHandler,
161 }
162
163 def __init__(self, output=sys.stdout, err=sys.stderr):
164 self._output = output
165 self._err = err
166
167 def handle_cmd(self, command, application):
168 """Handle running a given dot command from a user.
169
170 :type command: str
171 :param command: The full dot command string, e.g. ``.edit``,
172 of ``.profile prod``.
173
174 :type application: AWSShell
175 :param application: The application object.
176
177 """
178 parts = command.split()
179 cmd_name = parts[0][1:]
180 if cmd_name not in self.HANDLER_CLASSES:
181 self._unknown_cmd(parts, application)
182 else:
183 # Note we expect the class to support no-arg
184 # instantiation.
185 return self.HANDLER_CLASSES[cmd_name]().run(parts, application)
186
187 def _unknown_cmd(self, cmd_parts, application):
188 self._err.write("Unknown dot command: %s\n" % cmd_parts[0])
189
190
191class AWSShell(object):

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected