def _parse_command_line(args):
    task, taskname, args = _preparse(args)

    if not task:
        args = _parse_global_options(args)
        if not args:
            return None, []

        taskname = args.pop(0)
        task = environment.get_task(taskname)

        if not task:
            raise BuildFailure("Unknown task: %s" % taskname)

    if not isinstance(task, Task):
        raise BuildFailure("%s is not a Task" % taskname)

    if task.consume_args != float('inf'):
        args = task.parse_args(args)
    if task.consume_args > 0:
        args = _consume_nargs(task, args)

    return task, args
dataset/ETHPy150Open paver/paver/paver/tasks.py/_parse_command_line/original