예제 #1
0
def usage():
    result = ['Valid commands are:', Registry.registry().join_keys()]
    aliases = Aliases.instance()
    if aliases:
        result.append('\nand aliases are:')
        result.append(Join.join_words(aliases))
    return ' '.join(result)
예제 #2
0
def usage():
  result = ['Valid commands are:', REGISTRY.join_keys()]
  aliases = Aliases.instance()
  if aliases:
    result.append('\nand aliases are:')
    result.append(Join.join_words(aliases))
  return ' '.join(result)
예제 #3
0
def alias(instance, *path):
  aliases = Aliases.instance()
  if not path:
    Show.aliases()
    return
  alias = path[0]
  result = aliases.get_prefix(alias)

  if len(path) == 1:
    if result:
      LOGGER.info('Alias %s=%s', result[0], result[1])
    else:
      LOGGER.error('Don\'t understand alias %s.' % alias)
    return

  parts = (p.strip() for p in ' '.join(path[1:]).split('&'))
  parts = [p for p in parts if p]
  if not parts:
    LOGGER.error('Don\'t understand alias %s.', ' '.join(path))
    return

  if 'delete'.startswith(parts[0]):
    if len(parts) > 1:
      LOGGER.error('alias delete takes no arguments: %s.', ' '.join(path))

    elif not result:
      LOGGER.error('Don\'t understand alias %s.' % alias)
    else:
      del aliases[result[0]]
      LOGGER.info('Alias %s deleted.', result[0])
  else:
    aliases[alias] = parts
    LOGGER.info('Alias %s=%s', alias, parts)
예제 #4
0
def alias(_, *path):
    aliases = Aliases.instance()
    if not path:
        Show.aliases()
        return
    al = path[0]
    result = aliases.get_prefix(al)

    if len(path) == 1:
        if result:
            LOGGER.info('Alias %s=%s', result[0], ' '.join(result[1]))
        else:
            LOGGER.error('Don\'t understand alias %s.', al)
        return

    parts = (p.strip() for p in ' '.join(path[1:]).split('&'))
    parts = [p for p in parts if p]
    if not parts:
        LOGGER.error('Don\'t understand alias %s.', ' '.join(path))
        return

    if 'delete'.startswith(parts[0]):
        if len(parts) > 1:
            LOGGER.error('alias delete takes no arguments: %s.',
                         ' '.join(path))

        elif not result:
            LOGGER.error('Don\'t understand alias %s.', al)
        else:
            del aliases[result[0]]
            LOGGER.info('Alias %s deleted.', result[0])
    else:
        aliases[al] = parts
        LOGGER.info('Alias %s=%s', al, ' '.join(parts))
예제 #5
0
def _expand(command):
  aliases = Aliases.instance()
  stack = set()
  result = []

  def expand(*cmds):
    for command in cmds:
      parts = Split.split_words(command)
      name = parts.pop(0)
      alias = aliases.get_prefix(command)
      if alias:
        cmd, alias_commands = alias
        if cmd == command or name != REGISTRY.entry(name).name:
          assert cmd not in stack
          stack.add(cmd)
          expand(*alias_commands)
          stack.remove(cmd)
          continue

      result.append([REGISTRY.function(name), parts])
  expand(command)
  return result
예제 #6
0
def _expand(command):
  aliases = Aliases.instance()
  stack = set()
  result = []

  def expand(*cmds):
    for command in cmds:
      parts = Split.split_words(command)
      name = parts.pop(0)
      alias = aliases.get_prefix(command)
      if alias:
        cmd, alias_commands = alias
        registry = Register.get_or_none(name)
        if cmd == command or (not registry or registry[0] != name):
          assert cmd not in stack
          stack.add(cmd)
          expand(*alias_commands)
          stack.remove(cmd)
          continue

      result.append([Register.get(name), parts])
  expand(command)
  return result
예제 #7
0
def _expand(command):
    aliases = Aliases.instance()
    stack = set()
    result = []

    def expand(*cmds):
        for command in cmds:
            parts = Split.split_words(command)
            name = parts.pop(0)
            alias = aliases.get_prefix(command)
            if alias:
                cmd, alias_commands = alias
                if (cmd == command
                        or name != Registry.registry().entry(name).name):
                    assert cmd not in stack
                    stack.add(cmd)
                    expand(*alias_commands)
                    stack.remove(cmd)
                    continue

            result.append([Registry.registry().function(name), parts])

    expand(command)
    return result
예제 #8
0
def aliases(*_):
    al = Aliases.instance()
    if al:
        _info(al)
    else:
        LOGGER.info('    No aliases\n')
예제 #9
0
파일: Show.py 프로젝트: dasbavaria/echomesh
def aliases(*_):
  aliases = Aliases.instance()
  if aliases:
    _info(aliases)
  else:
    LOGGER.info('  No aliases')