Skip to content

Solved: [todo categories should show all categories #552]#614

Open
ThePayyavula wants to merge 4 commits into
pimutils:mainfrom
ThePayyavula:todo-categories
Open

Solved: [todo categories should show all categories #552]#614
ThePayyavula wants to merge 4 commits into
pimutils:mainfrom
ThePayyavula:todo-categories

Conversation

@ThePayyavula

Copy link
Copy Markdown

Added the todo categories that should show all categories

Introduce a new CLI command `categories` that prints all categories (JSON when using porcelain formatter, otherwise newline-separated). Implement Database.categories() to query DISTINCT category values from the categories table (ordered) and return them as a list of strings, ensuring the DB cursor is closed. Add a test in tests/test_cli.py to verify categories are extracted from an ICS item and shown by the command.
Ruff formatting

@WhyNotHugo WhyNotHugo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implementation should follow the same convention as existing commands, but the idea of this new command sounds good 👍

Comment thread todoman/cli.py
Comment on lines +696 to +699
porcelain = ctx.formatter_class == formatters.PorcelainFormatter
text = json.dumps(categories) if porcelain else "\n".join(categories)
click.echo(text)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DefaultFormatter and PorcelainFormatter should both implement a format_categories function which does the formatting, and here we just call click.echo(ctx.formatter.format_categories(categories)).

See how the list_command function is implemented below for reference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants