def parse_command_line(arguments): """Parse the SHOW command command-line arguments Returns a tuple containing three lists: - the list of ChangeInfo - the list of reviewers to add - the list of reviewers to delete :param arguments: a list of command-line arguments to parse :type arguments: list[str] :rtype: tuple[ChangeInfo, list[str], list[str]] """ changes, to_add, to_del = [], [], [] for argument in arguments: if argument in ('-h', '--help'): # Manually handle the --help flag Assign.display_help() if argument[0] == '+': to_add.append(argument[1:]) elif argument[0] == '-': to_del.append(argument[1:]) else: changes.append(argument) if not to_add and not to_del: fail('please specify reviewer(s) to add or delete') return fetch_change_list_or_fail(changes), to_add, to_del
def parse_command_line(arguments): """Parse the SHOW command command-line arguments :param arguments: a list of command-line arguments to parse :type arguments: list[str] :rtype: list[ChangeInfo] """ parser = argparse.ArgumentParser( description='Display code review scores for change(s)') expect_changes_as_positional(parser) cmdline = parser.parse_args(arguments) # Fetch changes details return fetch_change_list_or_fail(cmdline.changes)