Ejemplo n.º 1
0
def new_todo(
    text: t.Sequence[str],
    project: t.Optional[str],
    priority: t.Optional[str],
    tag: t.Sequence[str],
    parent: t.Sequence[str],
    force: bool,
) -> None:
    """
    Create new todo.
    """
    if len(text) > 1 and not force:
        from fml.client.dtmath.parse import DTMParser
        try:
            DTMParser().parse(text[-1])
        except (DTMParseException, ValueError, TypeError):
            pass
        else:
            if not click.confirm('This looks like an alarm. Continue?',
                                 default=True):
                return
    output.print_todo(Client().new_todo(
        ' '.join(text),
        project=get_default_project(project),
        priority=priority,
        tags=tag,
        parents=parent,
    ))
Ejemplo n.º 2
0
def finish_todo(target: t.Sequence[str],
                project: t.Optional[str] = None) -> None:
    """
    Finish todo. Target is either id, partial text of todo or "l" for last todo.
    """
    output.print_todo(Client().finish_todo(' '.join(target),
                                           get_default_project(project)))
Ejemplo n.º 3
0
def toggle_todo_wait(target: t.Sequence[str],
                     project: t.Optional[str] = None) -> None:
    """
    Toggle todo waiting status. Target is either id, partial text of todo or "l" for last todo.
    """
    output.print_todo(Client().toggle_todo_waiting(
        ' '.join(target), get_default_project(project)))
Ejemplo n.º 4
0
def comment_todo(
    todo: str,
    comment: str,
    project: t.Optional[str],
) -> None:
    """
    Add comment to todo.
    """
    output.print_todo(Client().comment_todo(
        todo, comment, project=get_default_project(project)))
Ejemplo n.º 5
0
def swap_priority_levels(
    first: str,
    second: str,
    project: t.Optional[str],
) -> None:
    """
    Create priority levels of priorities.
    """
    output.print_priorities(Client().swap_priority_levels(
        first=first,
        second=second,
        project=get_default_project(project),
    ))
Ejemplo n.º 6
0
def new_priority(
    name: t.Sequence[str],
    project: str,
    level: int,
) -> None:
    """
    Create a new priority.
    """
    output.print_priority(Client().new_priority(
        name=' '.join(name),
        level=level,
        project=get_default_project(project),
    ))
Ejemplo n.º 7
0
def change_priority(
    todo: str,
    priority: str,
    project: t.Optional[str],
    recursive: bool = False,
) -> None:
    """
    Modify todo priority.
    """
    output.print_todo(Client().modify_todo_priority(
        todo,
        priority,
        project=get_default_project(project),
        recursive=recursive,
    ))
Ejemplo n.º 8
0
def tag_todo(
    todo: str,
    tag: str,
    project: t.Optional[str],
    recursive: bool = False,
) -> None:
    """
    Tag todo. Target is either id, partial text of todo or "l" for last todo.
    """
    output.print_todo(Client().tag_todo(
        todo=todo,
        tag=tag,
        project=get_default_project(project),
        recursive=recursive,
    ))
Ejemplo n.º 9
0
def list_todos(
    history: bool = False,
    limit: int = 25,
    **kwargs,
) -> None:
    """
    List pending todos.
    """
    kwargs['project'] = get_default_project(kwargs['project'])
    if kwargs['query'] and kwargs['minimum_priority'] is None:
        kwargs['ignore_priority'] = True
    no_comments = kwargs.pop('no_comments')
    output.print_todos(
        Client().todo_history(limit=limit, **kwargs)
        if history else Client().active_todos(**kwargs),
        show_comments=not no_comments,
    )
Ejemplo n.º 10
0
def modify_todo_description(
    todo: str,
    description: t.Optional[str],
    project: t.Optional[str],
) -> None:
    """
    Modify todo description.
    """
    client = Client()
    project = get_default_project(project)
    if description is None:
        existing_todo = client.get_todo(todo, project=project)
        description = click.edit(existing_todo.text)
        if description is None:
            print('aborted')
            return
        description = description.rstrip('\n')
    output.print_todo(Client().modify_todo_description(todo,
                                                       description,
                                                       project=project))
Ejemplo n.º 11
0
def todos_throughput(
    project: t.Optional[str],
    tag: t.Optional[str],
    all_tasks: bool,
    ignore_priority: bool,
    minimum_priority: t.Optional[str],
    last_n_days: int,
) -> None:
    """
    Show todo throughput chart.
    """
    show_points(
        Client().todo_throughput(
            project=get_default_project(project),
            tag=tag,
            all_tasks=all_tasks,
            ignore_priority=ignore_priority,
            minimum_priority=minimum_priority,
            last_n_days=last_n_days,
        ),
        title='ToDo Throughput',
        y_label='ToDo/Day',
    )
Ejemplo n.º 12
0
def todos_burn_down(
    project: t.Optional[str],
    tag: t.Optional[str],
    all_tasks: bool,
    ignore_priority: bool,
    minimum_priority: t.Optional[str],
    last_n_days: int,
) -> None:
    """
    Show todo burndown chart.
    """
    show_points(
        Client().todo_burn_down(
            project=get_default_project(project),
            tag=tag,
            all_tasks=all_tasks,
            ignore_priority=ignore_priority,
            minimum_priority=minimum_priority,
            last_n_days=last_n_days,
        ),
        title='ToDo Burndown',
        y_label='ToDo Qty.',
    )
Ejemplo n.º 13
0
def list_priorities(project: str) -> None:
    """
    List priorities.
    """
    output.print_priorities(
        Client().list_priorities(project=get_default_project(project)))