def execute(context): aliases = load_aliases() log.title("Found %d alias(es)" % len(aliases)) for alias, alias_to in sorted(aliases.items()): log.write(" " * 4 + ("%-20s " + log.GRAY + "%s" + log.END) % (alias, alias_to)) return True
def get_twister_args(args=sys.argv[1:]): module_name = None command_name = None command_args = [] # read module and command if len(args) == 1: command_name = args[0] command_args = [] elif len(args) >= 2: module_name = args[0] command_name = args[1] command_args = args[2:] # -- handle the case when we have only parameters or command + parameter if module_name and module_name.startswith("--"): module_name = None if command_name and command_name.startswith("--"): command_name = module_name module_name = None command_args = args[1:] # -- if module name is incorrect, this might be a command.. if module_name and module_name not in list_modules(): command_name = module_name command_args = args[1:] module_name = None # -- handle the aliases if not module_name: aliases = load_aliases() if command_name in aliases.keys(): log.info("Using alias '%s' => '%s'" % (command_name, aliases[command_name])) alias_parts = re.split("\s+", aliases[command_name]) alias_args, command_name, module_name = get_twister_args(alias_parts) # sum up alias args and command args command_args = alias_args + command_args return command_args, command_name, module_name