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)
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)
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)
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))
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
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
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
def aliases(*_): al = Aliases.instance() if al: _info(al) else: LOGGER.info(' No aliases\n')
def aliases(*_): aliases = Aliases.instance() if aliases: _info(aliases) else: LOGGER.info(' No aliases')