initial commit
Adds the foundation of a _very_ simple taskopen implementation.
This commit is contained in:
commit
6a0c697a05
4 changed files with 80 additions and 0 deletions
1
.python-version
Normal file
1
.python-version
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
3.13
|
||||||
9
pyproject.toml
Normal file
9
pyproject.toml
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
[project]
|
||||||
|
name = "topen"
|
||||||
|
version = "0.1.0"
|
||||||
|
description = "Add your description here"
|
||||||
|
readme = "README.md"
|
||||||
|
requires-python = ">=3.13"
|
||||||
|
dependencies = [
|
||||||
|
"tasklib>=2.5.1",
|
||||||
|
]
|
||||||
50
topen
Executable file
50
topen
Executable file
|
|
@ -0,0 +1,50 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
# Open or create a note file
|
||||||
|
# for a taskwarrior task.
|
||||||
|
# Takes a taskwarrior ID or UUID for a single task.
|
||||||
|
# Edits an existing task note file,
|
||||||
|
# or creates a new one.
|
||||||
|
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
from tasklib import Task, TaskWarrior
|
||||||
|
|
||||||
|
TASK_DATA_DIR = "~/.local/share/task"
|
||||||
|
|
||||||
|
TASKNOTES_DIR = "~/.local/share/task/notes"
|
||||||
|
TASKNOTES_EXT = "md"
|
||||||
|
TASKNOTES_ANNOT = "Note"
|
||||||
|
|
||||||
|
tw = TaskWarrior(data_location=TASK_DATA_DIR)
|
||||||
|
|
||||||
|
args = sys.argv
|
||||||
|
|
||||||
|
if not len(args) == 2:
|
||||||
|
_ = sys.stderr.write("Please provide task ID as argument.\n")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
given_id = args[1]
|
||||||
|
|
||||||
|
try:
|
||||||
|
t = tw.tasks.get(id=given_id)
|
||||||
|
except Task.DoesNotExist:
|
||||||
|
t = tw.tasks.get(uuid=given_id)
|
||||||
|
|
||||||
|
_ = sys.stderr.write(f"Editing note for: {t['description']} ({t['uuid']})\n")
|
||||||
|
|
||||||
|
notes_file = Path(TASKNOTES_DIR).joinpath(f"{t['uuid']}.{TASKNOTES_EXT}")
|
||||||
|
|
||||||
|
proc = subprocess.Popen(f"nvim {notes_file}", shell=True)
|
||||||
|
_ = proc.wait()
|
||||||
|
|
||||||
|
def add_annotation_if_missing(task: Task) -> None:
|
||||||
|
for annot in t["annotations"]:
|
||||||
|
if annot["description"] == "Note":
|
||||||
|
return
|
||||||
|
t.add_annotation(TASKNOTES_ANNOT)
|
||||||
|
_ = sys.stderr.write(f"Added annotation.\n")
|
||||||
|
|
||||||
|
|
||||||
|
add_annotation_if_missing(t)
|
||||||
20
uv.lock
generated
Normal file
20
uv.lock
generated
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
version = 1
|
||||||
|
revision = 1
|
||||||
|
requires-python = ">=3.13"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tasklib"
|
||||||
|
version = "2.5.1"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/3e/50/3e876f39e31bad8783fd3fe117577cbf1dde836e161f8446631bde71aeb4/tasklib-2.5.1.tar.gz", hash = "sha256:5ccd731b52636dd10457a8b8d858cb0d026ffaab1e3e751baf791bf803e37d7b", size = 23805 }
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "topen"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = { virtual = "." }
|
||||||
|
dependencies = [
|
||||||
|
{ name = "tasklib" },
|
||||||
|
]
|
||||||
|
|
||||||
|
[package.metadata]
|
||||||
|
requires-dist = [{ name = "tasklib", specifier = ">=2.5.1" }]
|
||||||
Loading…
Add table
Add a link
Reference in a new issue