Exemple #1
0
def match(tags=typer.Argument(..., help=MATCH_TAGS_HELP)):
    """
    Search your notes you've tagged.
    """
    tags_list = [t.strip() for t in tags.split(",")]
    found_notes = Notes.find_by_tags(tags_list)
    typer.secho(f'Found {len(found_notes)} with tags in "{tags_list}"')
    print_notes(found_notes)
Exemple #2
0
def check_for_reminders(version: Optional[bool] = typer.Option(None, "--version", callback=version_callback)):
    reminders = Notes.due_reminders()
    if len(reminders) > 0:
        reminder_str = f"{len(reminders)} reminders due! Mark these as done soon."
        typer.secho(reminder_str, bold=True)
        typer.secho("-" * len(reminder_str))
        print_notes(reminders)
        typer.secho("-" * len(reminder_str))
Exemple #3
0
def ls(count: int = typer.Argument(10, help=LS_COUNT_HELP)):
    """
    Fetch the latest notes you've taken.
    """
    all_notes = Notes.all()
    if count == 0:
        count = len(all_notes)
    latest_notes = sorted(all_notes, reverse=True)[:count]
    typer.secho(f"Last {min(count, len(latest_notes))} notes", bold=True, underline=True)
    print_notes(latest_notes)
Exemple #4
0
def tasks(include_complete: bool = typer.Option(False), count: int = typer.Argument(10, help=LS_COUNT_HELP)):
    """
    Lists notes marked as Tasks.
    """
    all_tasks = Notes.all_tasks(include_complete)
    if count == 0:
        count = len(all_tasks)
    latest_notes = sorted(all_tasks, reverse=True)[:count]
    typer.secho(f"Last {min(count, len(latest_notes))} tasks:")
    print_notes(latest_notes)
Exemple #5
0
def mark_done(note_id: int = typer.Argument(...)):
    """
    Mark a task type note as done.
    """
    note = Notes.get_by_id(note_id)
    if note is not None:
        note.mark_as_done()
        note.update(run_magic=False)
        typer.secho(f"Marked note {note_id} as done.")

    else:
        typer.secho(f"No note under id {note_id} found.")
        raise typer.Abort()
Exemple #6
0
def edit(note_id: int = typer.Argument(..., help=EDIT_NOTE_ID_HELP)):
    """
    Edit a note you've taken.
    """
    note = Notes.get_by_id(note_id)
    if note is not None:
        typer.secho(note.pretty_str())
        update = typer.prompt("New content")
        note.content = update
        note.update()
        typer.secho(f"Note {note_id} updated.")
    else:
        typer.secho(f"No note of ID {note_id} found.")
        raise typer.Abort()
Exemple #7
0
def delete(
        note_id: int = typer.Argument(..., help=DELETE_NOTE_ID_HELP),
        force: bool = typer.Option(False),
):
    """
    Delete a note you've taken.
    """
    note = Notes.get_by_id(note_id)
    if note is not None:
        typer.secho(note.pretty_str())
        if force or typer.confirm("Are you sure you want to delete this note?", abort=True):
            note.delete()
            typer.secho(f"Note under ID {note_id} deleted.")
    else:
        typer.secho(f"No note under id {note_id} found.")
        raise typer.Abort()
Exemple #8
0
def search(term: str, limit: int = typer.Argument(5)):
    found_notes = Notes.search(term, limit)
    typer.secho(f'Found {len(found_notes)} notes matching "{term}"')
    print_notes(found_notes)