sorting todos
This commit is contained in:
parent
ddc8c90a30
commit
7367befa87
@ -7,13 +7,13 @@ A suite of tools for dealing with a directory of markdown files.
|
||||
- TODO: more flags
|
||||
- [ ] filters
|
||||
- [ ] sorting
|
||||
- TODO: add config file
|
||||
- TODO: add config file {by:2024-08-01}
|
||||
- [ ] make file types configurable
|
||||
- [ ] look in local dir, then XDG_HOME
|
||||
- DONE: support checkboxes
|
||||
- [x] scan lists
|
||||
- [x] percent complete
|
||||
- TODO: decide on more permanent name
|
||||
- TODO: decide on more permanent name {by:2024-08-15}
|
||||
- IDEA: recurring?
|
||||
- IDEA: track changes
|
||||
- DONE: add color {by: 2024-07-26}
|
||||
|
@ -10,6 +10,7 @@ from rich.console import Console
|
||||
console = Console()
|
||||
now = datetime.datetime.now()
|
||||
|
||||
SORT_ORDER = ["TODO", "IDEA", "DONE"]
|
||||
ALL_TODO_RE = re.compile(
|
||||
r"""^
|
||||
(?:\s*-\s*)?
|
||||
@ -31,7 +32,6 @@ TODO_TODO_RE = re.compile(
|
||||
|
||||
|
||||
def get_files(dirname):
|
||||
print(dirname, not dirname)
|
||||
if not dirname:
|
||||
dirname = "~/wiki/"
|
||||
else:
|
||||
@ -88,6 +88,15 @@ class TodoItem:
|
||||
" | ".join(self.tags),
|
||||
]
|
||||
|
||||
def status_sort(self):
|
||||
return SORT_ORDER.index(self.status)
|
||||
|
||||
def due(self):
|
||||
for t in self.tags:
|
||||
if t.startswith("by"):
|
||||
return t
|
||||
return "zzzzzzz" # sort to end
|
||||
|
||||
def subtask_nested(self):
|
||||
if not self.subtasks:
|
||||
return ""
|
||||
@ -169,6 +178,7 @@ def todos(dirname):
|
||||
output = [] # list of data
|
||||
for file in get_files(dirname):
|
||||
output += pull_todos(file)
|
||||
output.sort(key=lambda item: (item.status_sort(), item.due()), reverse=False)
|
||||
table = lod_table(output)
|
||||
console.print(table)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user