File tree Expand file tree Collapse file tree 3 files changed +28
-3
lines changed Expand file tree Collapse file tree 3 files changed +28
-3
lines changed Original file line number Diff line number Diff line change 5
5
*/test_*.py
6
6
*/__pycache__/*
7
7
*/site-packages/*
8
+ setup.py
8
9
9
10
[report]
10
11
exclude_lines =
Original file line number Diff line number Diff line change @@ -151,8 +151,11 @@ def reopen_task(self, task_id: int) -> None:
151
151
152
152
def main () -> None :
153
153
"""Handle CLI commands and execute appropriate actions."""
154
- parser = argparse .ArgumentParser (description = 'TaskNow - Minimalist Task Manager' )
155
- subparsers = parser .add_subparsers (dest = 'command' , required = True )
154
+ parser = argparse .ArgumentParser (
155
+ description = 'TaskNow - Minimalist Task Manager' ,
156
+ epilog = 'If no command is provided, defaults to showing the current task.'
157
+ )
158
+ subparsers = parser .add_subparsers (dest = 'command' )
156
159
157
160
# Show current task
158
161
subparsers .add_parser ('show' , help = 'Show current task' )
@@ -184,6 +187,8 @@ def main() -> None:
184
187
edit_parser .add_argument ('new_description' , nargs = '*' , help = 'New task description' )
185
188
186
189
args = parser .parse_args ()
190
+ if args .command is None :
191
+ args .command = 'show'
187
192
manager = TaskManager ()
188
193
189
194
try :
Original file line number Diff line number Diff line change @@ -350,4 +350,23 @@ def test_cli_exception_handling(capsys):
350
350
351
351
captured = capsys .readouterr ()
352
352
combined_output = captured .out + captured .err
353
- assert "Error: Simulated error" in combined_output
353
+ assert "Error: Simulated error" in combined_output
354
+
355
+
356
+ def test_cli_default_to_show (capsys , tmp_path ):
357
+ """Test CLI defaults to showing current task when no command is given."""
358
+ # Patch TASKS_FILE to use a temp file
359
+ temp_file = tmp_path / "tasks.json"
360
+ with patch ('main.TASKS_FILE' , str (temp_file )):
361
+ from main import TaskManager , main as cli_main
362
+
363
+ # Add a task so there is something to show
364
+ manager = TaskManager ()
365
+ manager .add_task ("Default show task" )
366
+
367
+ # Simulate running CLI with no arguments
368
+ with patch ('sys.argv' , ['main.py' ]):
369
+ cli_main ()
370
+
371
+ captured = capsys .readouterr ()
372
+ assert "Current task: Default show task" in captured .out
You can’t perform that action at this time.
0 commit comments