MCPcopy Index your code
hub / github.com/aws/aws-cli / ExternalAliasCommand

Class ExternalAliasCommand

awscli/alias.py:395–428  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

393
394
395class ExternalAliasCommand(BaseAliasCommand):
396 def __init__(self, alias_name, alias_value, invoker=subprocess.call):
397 """Command for external aliases
398
399 Executes command external of CLI as opposed to being a proxy
400 to another command.
401
402 :type alias_name: string
403 :param alias_name: The name of the alias
404
405 :type alias_value: string
406 :param alias_value: The parsed value of the alias. This can be
407 retrieved from `AliasLoader.get_aliases()[alias_name]`
408
409 :type invoker: callable
410 :param invoker: Callable to run arguments of external alias. The
411 signature should match that of ``subprocess.call``
412 """
413 super(ExternalAliasCommand, self).__init__(alias_name, alias_value)
414 self._invoker = invoker
415
416 def __call__(self, args, parsed_globals):
417 command_components = [self._alias_value[1:]]
418 command_components.extend(
419 compat_shell_quote(a, shell=True) for a in args
420 )
421 command = ' '.join(command_components)
422 LOG.debug(
423 'Using external alias %r with value: %r to run: %r',
424 self._alias_name,
425 self._alias_value,
426 command,
427 )
428 return self._invoker(command, shell=True)
429
430
431class InternalAliasSubCommand(BaseInternalAliasCommand):

Calls

no outgoing calls