fixed some bugs in todo add and made todo print ls after todo done

This commit is contained in:
2025-05-14 09:10:05 -07:00
parent 50609ea1a6
commit 41b726a85e

View File

@@ -212,7 +212,8 @@ def cmd_add(args):
entry = ' '.join(args.text) entry = ' '.join(args.text)
if not entry.startswith('[#'): if not entry.startswith('[#'):
console.print('[yellow]No priority; defaulting to Med (B).[/]') console.print('[yellow]No priority; defaulting to Med (B).[/]')
entry = '[#B] ' + entry today = date.today().strftime(DATE_FORMAT)
entry = f"[#{DEFAULT_PRIORITY}] ({today}) {entry}"
if '@' not in entry: if '@' not in entry:
console.print('[yellow]No tag; defaulting to @misc.[/]') console.print('[yellow]No tag; defaulting to @misc.[/]')
entry += ' @misc' entry += ' @misc'
@@ -222,6 +223,8 @@ def cmd_add(args):
tasks.append(t) tasks.append(t)
write_tasks(tasks) write_tasks(tasks)
console.print(f'[green]Added:[/] {t.description}') console.print(f'[green]Added:[/] {t.description}')
else:
console.print(f'[red]Failed to parse task line:[/] {entry}')
else: else:
desc = Prompt.ask('Task description') desc = Prompt.ask('Task description')
prio = Prompt.ask('Priority (A=High,B=Med,C=Low)', choices=['A','B','C'], default=DEFAULT_PRIORITY) prio = Prompt.ask('Priority (A=High,B=Med,C=Low)', choices=['A','B','C'], default=DEFAULT_PRIORITY)
@@ -243,6 +246,7 @@ def cmd_done(args):
all_tasks[idx] = all_tasks[idx].mark_done() all_tasks[idx] = all_tasks[idx].mark_done()
write_tasks(all_tasks) write_tasks(all_tasks)
console.print(f"[green]Completed:[/] {all_tasks[idx].description}") console.print(f"[green]Completed:[/] {all_tasks[idx].description}")
cmd_ls(argparse.Namespace(sort=None))
except: except:
console.print('[red]Invalid task number[/]') console.print('[red]Invalid task number[/]')