modo
This commit is contained in:
parent
279b45b1ee
commit
7907bee106
14
README.md
14
README.md
@ -5,18 +5,24 @@ A suite of tools for dealing with a directory of markdown files.
|
||||
## Tasks
|
||||
|
||||
- TODO: improve inline help
|
||||
- TODO: more flags
|
||||
- DONE: more flags
|
||||
- [x] filters
|
||||
- [x] sorting
|
||||
- [ ] reverse sort
|
||||
- TODO: add config file {by:2024-08-01}
|
||||
- [x] reverse sort
|
||||
- TODO: add config file {by:2024-09-01}
|
||||
- [ ] make file types configurable
|
||||
- [ ] look in local dir, then XDG_HOME
|
||||
- DONE: support checkboxes
|
||||
- [x] scan lists
|
||||
- [x] percent complete
|
||||
- DONE: decide on more permanent name {by:2024-08-15}
|
||||
- IDEA: recurring?
|
||||
- IDEA: track changes
|
||||
- IDEA: modify files
|
||||
- [ ] quick add
|
||||
- [ ] check box -> completion
|
||||
- [ ] finish (assigned temp tags?)
|
||||
- [ ] sort in file
|
||||
maybe requires a special section like ## Tasks
|
||||
- DONE: decide on more permanent name {by:2024-08-15}
|
||||
- DONE: add color {by: 2024-07-26}
|
||||
- DONE: support multi-tags {like:this} {by: 2024-07-26}
|
||||
|
@ -33,7 +33,7 @@ TODO_TODO_RE = re.compile(
|
||||
|
||||
def get_files(dirname):
|
||||
if not dirname:
|
||||
dirname = "~/wiki/"
|
||||
dirname = "."
|
||||
else:
|
||||
dirname = dirname[0]
|
||||
p = pathlib.Path(dirname).expanduser()
|
||||
@ -55,6 +55,19 @@ def lod_table(data: list["TodoItem"]) -> Table | str:
|
||||
return table
|
||||
|
||||
|
||||
def do_sorting(output, sort, default_sort, sort_factory):
|
||||
reverse = False
|
||||
if not sort:
|
||||
sort = default_sort
|
||||
else:
|
||||
if sort[0] == "-":
|
||||
reverse = True
|
||||
sort = sort[1:]
|
||||
sort = sort.split(",")
|
||||
sort_func = sort_factory(sort)
|
||||
output.sort(key=sort_func, reverse=reverse)
|
||||
|
||||
|
||||
@click.group()
|
||||
def cli():
|
||||
pass
|
||||
@ -210,12 +223,7 @@ def todos(dirname, sort, filter):
|
||||
output = apply_filter(output, rule)
|
||||
|
||||
# do sorting
|
||||
if not sort:
|
||||
sort = ["status", "due"]
|
||||
else:
|
||||
sort = sort.split(",")
|
||||
sort_func = get_todo_sort_func(sort)
|
||||
output.sort(key=sort_func)
|
||||
do_sorting(output, sort, ["status", "due"], get_todo_sort_func)
|
||||
|
||||
# display
|
||||
table = lod_table(output)
|
||||
@ -303,12 +311,7 @@ def ls(dirname, sort):
|
||||
)
|
||||
|
||||
# sort
|
||||
if not sort:
|
||||
sort = ["file", "modified"]
|
||||
else:
|
||||
sort = sort.split(",")
|
||||
sort_func = get_ls_sort_func(sort)
|
||||
output.sort(key=sort_func)
|
||||
do_sorting(output, sort, ["file", "modified"], get_ls_sort_func)
|
||||
|
||||
# display
|
||||
table = lod_table(output)
|
||||
|
Loading…
Reference in New Issue
Block a user