cli-todo-jd 0.2.0__tar.gz → 0.2.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {cli_todo_jd-0.2.0 → cli_todo_jd-0.2.1}/PKG-INFO +1 -1
- {cli_todo_jd-0.2.0 → cli_todo_jd-0.2.1}/cli_todo_jd/cli_entry.py +38 -3
- {cli_todo_jd-0.2.0 → cli_todo_jd-0.2.1}/cli_todo_jd/main.py +53 -14
- {cli_todo_jd-0.2.0 → cli_todo_jd-0.2.1}/cli_todo_jd.egg-info/PKG-INFO +1 -1
- {cli_todo_jd-0.2.0 → cli_todo_jd-0.2.1}/pyproject.toml +2 -2
- {cli_todo_jd-0.2.0 → cli_todo_jd-0.2.1}/README.md +0 -0
- {cli_todo_jd-0.2.0 → cli_todo_jd-0.2.1}/cli_todo_jd/__init__.py +0 -0
- {cli_todo_jd-0.2.0 → cli_todo_jd-0.2.1}/cli_todo_jd/storage/__init__.py +0 -0
- {cli_todo_jd-0.2.0 → cli_todo_jd-0.2.1}/cli_todo_jd/storage/migrate.py +0 -0
- {cli_todo_jd-0.2.0 → cli_todo_jd-0.2.1}/cli_todo_jd/storage/schema.py +0 -0
- {cli_todo_jd-0.2.0 → cli_todo_jd-0.2.1}/cli_todo_jd.egg-info/SOURCES.txt +0 -0
- {cli_todo_jd-0.2.0 → cli_todo_jd-0.2.1}/cli_todo_jd.egg-info/dependency_links.txt +0 -0
- {cli_todo_jd-0.2.0 → cli_todo_jd-0.2.1}/cli_todo_jd.egg-info/entry_points.txt +0 -0
- {cli_todo_jd-0.2.0 → cli_todo_jd-0.2.1}/cli_todo_jd.egg-info/requires.txt +0 -0
- {cli_todo_jd-0.2.0 → cli_todo_jd-0.2.1}/cli_todo_jd.egg-info/top_level.txt +0 -0
- {cli_todo_jd-0.2.0 → cli_todo_jd-0.2.1}/setup.cfg +0 -0
|
@@ -37,8 +37,43 @@ def add(
|
|
|
37
37
|
@app.command(name="list")
|
|
38
38
|
def list_(
|
|
39
39
|
filepath: Path = typer.Option(Path(".todo_list.db"), "--filepath", "-f"),
|
|
40
|
+
show_all: bool = typer.Option(
|
|
41
|
+
False, "--all", "-a", help="Show all todos (open + done)."
|
|
42
|
+
),
|
|
43
|
+
show_done: bool = typer.Option(
|
|
44
|
+
False, "--done", "-d", help="Show only completed todos."
|
|
45
|
+
),
|
|
46
|
+
show_open: bool = typer.Option(
|
|
47
|
+
False, "--open", "-o", help="Show only open todos (default)."
|
|
48
|
+
),
|
|
40
49
|
) -> None:
|
|
41
|
-
|
|
50
|
+
"""List todos.
|
|
51
|
+
|
|
52
|
+
Examples
|
|
53
|
+
--------
|
|
54
|
+
- todo list
|
|
55
|
+
- todo list --done
|
|
56
|
+
- todo list --all
|
|
57
|
+
- todo list -a
|
|
58
|
+
"""
|
|
59
|
+
|
|
60
|
+
# Choose filter. If nothing specified, default to open.
|
|
61
|
+
# If the user specifies multiple flags, error out.
|
|
62
|
+
flags = [show_all, show_done, show_open]
|
|
63
|
+
if sum(1 for f in flags if f) > 1:
|
|
64
|
+
raise typer.BadParameter(
|
|
65
|
+
"Use only one of: --all / -a, --done / -d, --open / -o"
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
if show_all:
|
|
69
|
+
show = "all"
|
|
70
|
+
elif show_done:
|
|
71
|
+
show = "done"
|
|
72
|
+
else:
|
|
73
|
+
# default is open (or explicit --open)
|
|
74
|
+
show = "open"
|
|
75
|
+
|
|
76
|
+
list_items_on_list(filepath, show=show)
|
|
42
77
|
|
|
43
78
|
|
|
44
79
|
@app.command()
|
|
@@ -80,7 +115,7 @@ def done(
|
|
|
80
115
|
filepath: Path = typer.Option(Path(".todo_list.db"), "--filepath", "-f"),
|
|
81
116
|
) -> None:
|
|
82
117
|
mark_item_as_done(index, filepath)
|
|
83
|
-
|
|
118
|
+
list_items_on_list(filepath=filepath, show="all")
|
|
84
119
|
|
|
85
120
|
|
|
86
121
|
@app.command()
|
|
@@ -89,7 +124,7 @@ def not_done(
|
|
|
89
124
|
filepath: Path = typer.Option(Path(".todo_list.db"), "--filepath", "-f"),
|
|
90
125
|
) -> None:
|
|
91
126
|
mark_item_as_not_done(index, filepath)
|
|
92
|
-
|
|
127
|
+
list_items_on_list(filepath=filepath, show="all")
|
|
93
128
|
|
|
94
129
|
|
|
95
130
|
def parser_optional_args(parser: ArgumentParser):
|
|
@@ -45,13 +45,51 @@ class TodoApp:
|
|
|
45
45
|
print(f'Added todo: "{item}"')
|
|
46
46
|
self._check_and_load_todos(self.file_path_to_db)
|
|
47
47
|
|
|
48
|
-
def list_todos(self) -> None:
|
|
48
|
+
def list_todos(self, *, show: str = "open") -> None:
|
|
49
|
+
"""List todos.
|
|
50
|
+
|
|
51
|
+
Parameters
|
|
52
|
+
----------
|
|
53
|
+
show:
|
|
54
|
+
"open" (default), "done", or "all".
|
|
55
|
+
"""
|
|
56
|
+
show = (show or "open").lower()
|
|
57
|
+
if show not in {"open", "done", "all"}:
|
|
58
|
+
print("Error: show must be one of: open, done, all")
|
|
59
|
+
return
|
|
60
|
+
|
|
49
61
|
# Always read fresh so output reflects the DB
|
|
50
62
|
self._check_and_load_todos(self.file_path_to_db)
|
|
51
63
|
if not self.todos:
|
|
52
64
|
print("No todos found.")
|
|
53
65
|
return
|
|
54
|
-
|
|
66
|
+
|
|
67
|
+
if show == "all":
|
|
68
|
+
self._table_print(title="Todos")
|
|
69
|
+
return
|
|
70
|
+
|
|
71
|
+
# Filter in-memory to keep this change minimal. (You can later filter in SQL.)
|
|
72
|
+
filtered_todos: list[str] = []
|
|
73
|
+
filtered_status: list[int] = []
|
|
74
|
+
for todo, done in zip(self.todos, self.status, strict=False):
|
|
75
|
+
if show == "open" and not done:
|
|
76
|
+
filtered_todos.append(todo)
|
|
77
|
+
filtered_status.append(done)
|
|
78
|
+
elif show == "done" and done:
|
|
79
|
+
filtered_todos.append(todo)
|
|
80
|
+
filtered_status.append(done)
|
|
81
|
+
|
|
82
|
+
if not filtered_todos:
|
|
83
|
+
print("No todos found.")
|
|
84
|
+
return
|
|
85
|
+
|
|
86
|
+
original_todos, original_status = self.todos, self.status
|
|
87
|
+
try:
|
|
88
|
+
self.todos, self.status = filtered_todos, filtered_status
|
|
89
|
+
title = "Open todos" if show == "open" else "Completed todos"
|
|
90
|
+
self._table_print(title=title)
|
|
91
|
+
finally:
|
|
92
|
+
self.todos, self.status = original_todos, original_status
|
|
55
93
|
|
|
56
94
|
def remove_todo(self, index: int) -> None:
|
|
57
95
|
# Maintain current UX: index refers to the displayed (1-based) ordering.
|
|
@@ -281,7 +319,7 @@ def create_list(file_path_to_db: str = "./.todo_list.db"):
|
|
|
281
319
|
|
|
282
320
|
Parameters
|
|
283
321
|
----------
|
|
284
|
-
|
|
322
|
+
file_path_to_db : str, optional
|
|
285
323
|
The file path to the JSON file for storing todos, by default "./.todo_list.db"
|
|
286
324
|
|
|
287
325
|
Returns
|
|
@@ -309,17 +347,18 @@ def add_item_to_list(item: str, filepath: str):
|
|
|
309
347
|
app.list_todos()
|
|
310
348
|
|
|
311
349
|
|
|
312
|
-
def list_items_on_list(filepath: str):
|
|
313
|
-
"""
|
|
314
|
-
List all items in the todo list.
|
|
350
|
+
def list_items_on_list(filepath: str, show: str = "open"):
|
|
351
|
+
"""List items in the todo list.
|
|
315
352
|
|
|
316
353
|
Parameters
|
|
317
354
|
----------
|
|
318
|
-
filepath
|
|
319
|
-
The
|
|
355
|
+
filepath:
|
|
356
|
+
The SQLite database path.
|
|
357
|
+
show:
|
|
358
|
+
"open" (default), "done", or "all".
|
|
320
359
|
"""
|
|
321
360
|
app = create_list(file_path_to_db=filepath)
|
|
322
|
-
app.list_todos()
|
|
361
|
+
app.list_todos(show=show)
|
|
323
362
|
|
|
324
363
|
|
|
325
364
|
def remove_item_from_list(index: int, filepath: str):
|
|
@@ -388,7 +427,7 @@ def cli_menu(filepath="./.todo_list.db"):
|
|
|
388
427
|
item = questionary.text("Enter the todo item:").ask()
|
|
389
428
|
app.add_todo(item)
|
|
390
429
|
elif action == "List todos":
|
|
391
|
-
app.list_todos()
|
|
430
|
+
app.list_todos(show="all")
|
|
392
431
|
elif action == "Update todo status":
|
|
393
432
|
if not app.todos:
|
|
394
433
|
print("No todos to update.")
|
|
@@ -398,7 +437,7 @@ def cli_menu(filepath="./.todo_list.db"):
|
|
|
398
437
|
choices=["<Back>"] + app.todos,
|
|
399
438
|
).ask()
|
|
400
439
|
|
|
401
|
-
if todo_choice == "<Back>":
|
|
440
|
+
if todo_choice == "<Back>" or todo_choice is None:
|
|
402
441
|
continue
|
|
403
442
|
|
|
404
443
|
todo_index = app.todos.index(todo_choice) + 1
|
|
@@ -407,13 +446,13 @@ def cli_menu(filepath="./.todo_list.db"):
|
|
|
407
446
|
choices=["Done", "Not Done", "<Back>"],
|
|
408
447
|
).ask()
|
|
409
448
|
|
|
410
|
-
if status_choice == "<Back>":
|
|
449
|
+
if status_choice == "<Back>" or status_choice is None:
|
|
411
450
|
continue
|
|
412
451
|
elif status_choice == "Done":
|
|
413
452
|
app.mark_as_done(todo_index)
|
|
414
453
|
elif status_choice == "Not Done":
|
|
415
454
|
app.mark_as_not_done(todo_index)
|
|
416
|
-
app.list_todos()
|
|
455
|
+
app.list_todos(show="all")
|
|
417
456
|
elif action == "Remove todo":
|
|
418
457
|
if not app.todos:
|
|
419
458
|
print("No todos to remove.")
|
|
@@ -423,7 +462,7 @@ def cli_menu(filepath="./.todo_list.db"):
|
|
|
423
462
|
choices=["<Back>"] + app.todos,
|
|
424
463
|
).ask()
|
|
425
464
|
|
|
426
|
-
if todo_choice == "<Back>":
|
|
465
|
+
if todo_choice == "<Back>" or todo_choice is None:
|
|
427
466
|
continue
|
|
428
467
|
|
|
429
468
|
todo_to_remove = app.todos.index(todo_choice) + 1
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "cli-todo-jd"
|
|
3
|
-
version = "0.2.
|
|
3
|
+
version = "0.2.1"
|
|
4
4
|
description = "Add your description here"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.10"
|
|
@@ -23,7 +23,7 @@ todo = "cli_todo_jd.cli_entry:app"
|
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
[tool.bumpversion]
|
|
26
|
-
current_version = "0.2.
|
|
26
|
+
current_version = "0.2.1"
|
|
27
27
|
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)"
|
|
28
28
|
serialize = ["{major}.{minor}.{patch}"]
|
|
29
29
|
search = "{current_version}"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|