Skip to content

Print message if task not in tasks.json#5

Open
RamVasuthevan wants to merge 1 commit intocmccandless:masterfrom
RamVasuthevan:print-message-if-task-not-in-tasks-json
Open

Print message if task not in tasks.json#5
RamVasuthevan wants to merge 1 commit intocmccandless:masterfrom
RamVasuthevan:print-message-if-task-not-in-tasks-json

Conversation

@RamVasuthevan
Copy link

Currently, if we try to run a task that is not in tasks, we get a non-descriptive error like:

(Private-Website) ram@Rams-MacBook-Air ~/c/Private-Website (vstask-to-run-tasks)> vstask Create
Traceback (most recent call last):
  File "/Users/ram/.local/share/virtualenvs/Private-Website-b_cN1wWk/bin/vstask", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/Users/ram/.local/share/virtualenvs/Private-Website-b_cN1wWk/lib/python3.12/site-packages/vstask/vstask.py", line 92, in main
    if run_task(tasks[task_name], root) != 0:
                ~~~~~^^^^^^^^^^^
KeyError: 'Create'

We will now get a more useful error message like:

(vstask) ram@Rams-MacBook-Air ~/c/vstask (print-message-if-task-not-in-tasks-json)> vstask Create
Unable to find Create in tasks.json

Copy link

@Calinou Calinou left a comment

Choose a reason for hiding this comment

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

Code looks good to me.


with timed(opts.time):
for task_name in opts.tasks:
if task_name not in tasks.keys():
Copy link
Owner

Choose a reason for hiding this comment

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

Change to if task_name not in tasks:

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.

3 participants