Example #1
0
def ungat(tag, docs):
    """Remove TAG from DOCS. Docs are space-separated.

    > dt ungat current old_list.txt old_notes.txt

    See also `dt untag --help`.
    """
    with get_ti() as ti:
        ti.untag(docs=docs, tags=tag)
Example #2
0
def gat(tag, docs):
    """Apply TAG to DOCS. Docs are space-separated.

    > dt gat list todo.txt movies.txt

    See also `dt tag --help`.
    """
    with get_ti() as ti:
        ti.tag(docs=docs, tags=tag)
Example #3
0
def untag(doc, tags):
    """Remove TAGS from DOC. Tags are space-separated.

    > dt untag old_list.txt current important

    See also `dt ungat --help`.
    """
    with get_ti() as ti:
        ti.untag(docs=doc, tags=tags)
Example #4
0
def show(ctx, verbose):
    """Print either docs or tags to stdout.

    > dt show tags

    > dt show docs
    """
    ctx.obj["ti"] = get_ti()
    ctx.obj["verbose"] = verbose
Example #5
0
def tag(doc, tags):
    """Apply TAGS to DOC. Tags are space-separated.

    > dt tag todo.txt list gtd

    See also `dt gat --help`.
    """
    with get_ti() as ti:
        ti.tag(docs=doc, tags=tags)
Example #6
0
def tag(tag: str):
    """Remove TAG from the tag index. (i.e. remove TAG from all docs.)

    > dt remove tag old_tag
    """
    with get_ti() as ti:
        try:
            ti.remove_tag(tag=tag)
        except ValueError:
            click.echo(f"Tag '{tag}' not in index.")
Example #7
0
def doc(doc: str):
    """Remove DOC from the tag index. (i.e. remove all tags from DOC.)

    > dt remove doc old_file.txt
    """
    with get_ti() as ti:
        try:
            ti.remove_doc(doc_name=doc)
        except ValueError:
            click.echo(f"Doc '{doc}' not in index.")
Example #8
0
def find(query, verbose):
    """Find docs with a boolean tag QUERY.

    > dt find school or (book and class)
    """
    query = " ".join(query)
    ti = get_ti()
    results = ti.query(query=query)
    for doc in sorted(results):
        if not verbose:
            click.echo(doc)
        else:
            click.echo(f"{doc} ({tag_str(ti=ti,doc=doc)})")
Example #9
0
def merge(old_tags, new_tag):
    """Merge OLD_TAGS into NEW_TAG. Old tags are space separated. New tag is created if it does not exist.

    > dt merge dairy diary

    (merges "dairy" into "diary")
    
    > dt merge lists lits list

    (merges "lists" and "lits" into "list")
    """
    with get_ti() as ti:
        ti.merge_tags(old_tags=old_tags, new_tag=new_tag)
Example #10
0
def start():
    """Create a tag index at ~/.dtdb.json (or $DTDB if it is set).
    """
    ti = get_ti()