Add --ignore option to skip projects from report. Update deps

This commit is contained in:
Alex Kelly 2025-10-24 09:39:57 -04:00
commit b0457b3f9e
3 changed files with 1509 additions and 972 deletions

2456
poetry.lock generated

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
[tool.poetry]
name = "task-status"
version = "0.3.1"
version = "0.4.1"
description = "Utility to get status data built from taskwarrior"
authors = ["Alex Kelly <alex.kelly@franklin.edu>"]
@ -9,7 +9,7 @@ python = "^3.9"
click = "^8.0.1"
python-dateutil = "^2.8.2"
[tool.poetry.dev-dependencies]
[tool.poetry.group.dev.dependencies]
pytest = "^6.2.4"
flake8 = "^3.9.2"
python-semantic-release = "^7.19.1"

View file

@ -20,14 +20,17 @@ def validate_tasks(tasks):
return tasks
@click.command()
@click.version_option(__version__, prog_name="task-status")
@click.option("--uuid", is_flag=True, help="Display the task UUID")
@click.option("--header", is_flag=True, help="Display date header")
@click.option("--bullet", default="*", help="Character to use for bullets in list")
@click.option("--header", is_flag=True, help="Display date header")
@click.option(
"--ignore", multiple=True, help="Project(s) to ignore in the report (can be used multiple times)"
)
@click.option(
"--sort", is_flag=True, default=True, help="Alphabetically sort by project"
)
def main(uuid, header, bullet, sort):
@click.option("--uuid", is_flag=True, help="Display the task UUID")
@click.version_option(__version__, prog_name="task-status")
def main(uuid, header, bullet, sort, ignore):
"""Main function that does all the work for task_status"""
today = date.today()
last_monday = today + relativedelta(weekday=MO(-2))
@ -47,6 +50,10 @@ def main(uuid, header, bullet, sort):
check=True,
)
entries = validate_tasks(json.loads(tasks.stdout.decode()))
# Convert ignore tuple to set for faster lookup
ignored_projects = set(ignore)
output_list = []
project_list = []
if header:
@ -54,10 +61,10 @@ def main(uuid, header, bullet, sort):
for status_projects, status_entries in itertools.groupby(
entries, key=operator.itemgetter("project")
):
if status_projects not in project_list:
# Skip ignored projects
if status_projects not in ignored_projects and status_projects not in project_list:
project_list.append(status_projects)
output_list.append(list(status_entries))
output_list.append(list(status_entries))
if sort:
project_list.sort()
for project in project_list: