Skip to content

Add option for printing the description in list #449

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Add option for printing the description in list
  • Loading branch information
gustafla committed Aug 4, 2021
commit a8177d3b1ca01fb9cff5a230a99b0588d99f6de5
10 changes: 9 additions & 1 deletion todoman/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,14 @@ 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 +639,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"]))
3 changes: 2 additions & 1 deletion todoman/formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ 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 +100,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