diff --git a/README.md b/README.md index 04e2035..08f330a 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,9 @@ ## Quickstart -Install: `pip install todo-today-cli` +Install: `pipx install todo-today-cli`. + +Install from source: `git clone git@github.com:vighneshiyer/today`, `cd today`, `pipx install -e .`. Create a file (`tasks.md`) and add the following: diff --git a/today/cli.py b/today/cli.py index f0e70bb..263d61a 100644 --- a/today/cli.py +++ b/today/cli.py @@ -11,7 +11,7 @@ from rich.console import Console from rich.markdown import Markdown -from today.task import PriorityAttribute, Task, task_sorter, days +from today.task import Task, task_sorter, days from today.parser import parse_markdown @@ -112,10 +112,8 @@ def parse_task_files(args: CliArgs) -> List[Task]: return tasks_visible -def display_specific_task( - task: Task, task_id: int, today: date, console: Console -) -> None: - details = task.details(task_id, today) +def display_specific_task(task: Task, today: date, console: Console) -> None: + details = task.details(today) console.print("") console.print(Markdown(details)) console.print("") @@ -149,19 +147,22 @@ def tasks_to_tree(args: CliArgs, tasks: List[Task]) -> Tree: priority_tasks = [t for t in tasks if t.attrs.priority_attr is not None] other_tasks = [t for t in tasks if t.attrs.priority_attr is None] - priority_label = tree.add("[bold]Priority Tasks[/bold]") - for i, task in enumerate(priority_tasks): - priority_label.add( - # f"[bold]{i}[/bold] - [blue]{' / '.join(task.path)}[/blue] [blue bold]➔[/blue bold] {task.title} {Markdown(task.summary(args.today))} ([red italic]{task.file_path.relative_to(args.task_dir)}:{task.line_number}[/red italic])" - Markdown( - f"**{i}** - {' / '.join(task.path)} → {task.title} {task.summary(args.today)} (*{task.file_path.relative_to(args.task_dir)}:{task.line_number}*)" + if len(priority_tasks) > 0: + priority_label = tree.add("[bold]Priority Tasks[/bold]") + for i, task in enumerate(priority_tasks): + priority_label.add( + # f"[bold]{i}[/bold] - [blue]{' / '.join(task.path)}[/blue] [blue bold]➔[/blue bold] {task.title} {Markdown(task.summary(args.today))} ([red italic]{task.file_path.relative_to(args.task_dir)}:{task.line_number}[/red italic])" + Markdown( + f"**{i}** - {' / '.join(task.path)} → {task.title} {task.summary(args.today)} (*{task.file_path.relative_to(args.task_dir)}:{task.line_number}*)" + ) ) - ) def add_to_tree(task: Task, tree: Tree, task_idx: int, first_call: bool) -> Tree: if len(task.path) == 0: # Base case parent = tree.add( - Markdown(f"**{task_idx}** - {task.title} {task.summary(args.today)}") + Markdown( + f"**{task_idx}** - {task.title} {task.summary(args.today)} (*:{task.line_number}*)" + ) ) if task.subtasks: for subtask in task.subtasks: diff --git a/today/scripts/today.py b/today/scripts/today.py index 31354da..aeeaf57 100644 --- a/today/scripts/today.py +++ b/today/scripts/today.py @@ -25,7 +25,7 @@ def run(args) -> None: console.print(f"The task_id {args.task_id} does not exist") sys.exit(1) task = tasks[cli_args.task_id] - display_specific_task(task, cli_args.task_id, cli_args.today, console) + display_specific_task(task, cli_args.today, console) sys.exit(0) tree = tasks_to_tree(cli_args, tasks) diff --git a/today/task.py b/today/task.py index 7b2b177..69dbfa8 100644 --- a/today/task.py +++ b/today/task.py @@ -147,16 +147,20 @@ def is_displayed(self, today: date, lookahead_days: int = 0) -> bool: def summary(self, today: date) -> str: # Returns a Markdown string date_summary = self.attrs.date_attr.summary(today) + # pri_summary = ( + # (self.attrs.priority_attr.summary() + " ") + # if self.attrs.priority_attr + # else "" + # ) pri_summary = ( - (self.attrs.priority_attr.summary() + " ") - if self.attrs.priority_attr - else "" + "" # don't include task priorities in the summaries shown in the tree ) return pri_summary + date_summary - def details(self, task_id: int, today: date) -> str: # Returns a Markdown string + def details(self, today: date) -> str: # Returns a Markdown string string = "" - string += f"**Title**: {self.title} (id = `{task_id}`) \n" + string += f"**Title**: {self.title} \n" + string += self.attrs.date_attr.details(today) if len(self.description) > 0: string += "**Description**: \n\n" string += self.description