Beispiel #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,
    ))
Beispiel #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)))
Beispiel #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)))
Beispiel #4
0
def register_dependency(
    parent: str,
    task: str,
) -> None:
    """
    Register task as subtask of other task
    """
    output.print_todo(Client().register_dependency(parent, task))
Beispiel #5
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)))
Beispiel #6
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,
    ))
Beispiel #7
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,
    ))
Beispiel #8
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))