Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option for printing the description in list #449

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion todoman/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,12 @@ def move(ctx, list, ids):
'"NEEDS-ACTION", "CANCELLED", "COMPLETED", "IN-PROCESS" or "ANY"'
),
)
@click.option(
"--description/--no-description",
"-v",
default=False,
help=("Show description. Defaults to false."),
)
@catch_errors
def list(ctx, *args, **kwargs):
"""
Expand All @@ -631,4 +637,4 @@ def list(ctx, *args, **kwargs):
)

todos = ctx.db.todos(**kwargs)
click.echo(ctx.formatter.compact_multiple(todos, hide_list))
click.echo(ctx.formatter.compact_multiple(todos, hide_list, kwargs["description"]))
5 changes: 4 additions & 1 deletion todoman/formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ def simple_action(self, action: str, todo: Todo) -> str:
def compact(self, todo: Todo) -> str:
return self.compact_multiple([todo])

def compact_multiple(self, todos: Iterable[Todo], hide_list=False) -> str:
def compact_multiple(
self, todos: Iterable[Todo], hide_list=False, description=False
) -> str:
table = []
for todo in todos:
completed = "X" if todo.is_completed else " "
Expand Down Expand Up @@ -100,6 +102,7 @@ def compact_multiple(self, todos: Iterable[Todo], hide_list=False) -> str:
priority,
f"{due} {recurring}",
summary,
todo.description if description else None,
]
)

Expand Down
1 change: 1 addition & 0 deletions todoman/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,7 @@ def todos(
start=None,
startable=False,
status="NEEDS-ACTION,IN-PROCESS",
description=False,
) -> Iterable[Todo]:
"""
Returns filtered cached todos, in a specified order.
Expand Down