Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add command suggestions feature #1022

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

krepysh
Copy link

@krepysh krepysh commented Feb 9, 2025

🚀 Description

💁 Why is this change needed?

This update enhances Invoke’s error handling by providing command suggestions when a command is mistyped, similar to how Git and Django’s manage.py handle such errors.

This feature is especially useful for projects with complex command structures, particularly those involving multiple namespaces and deep nesting. In such cases, offering quick suggestions from the CLI tool significantly improves the user experience and efficiency.

🧑‍💻 Technical details

I implemented pattern matching using the difflib module, which is part of Python’s standard library, so no additional dependencies are required.

Additionally, a new argument, --[no-]suggestions (or -S), was introduced which defaults to True.

📷 Demonstration

invoke_public_demo.mov

♻️ Related to

This PR addresses issue #1021 and also related to PR #1010

@krepysh krepysh force-pushed the 1021_add_commands_suggestions branch 2 times, most recently from ce0d78f to ae33263 Compare February 10, 2025 04:56
@krepysh krepysh force-pushed the 1021_add_commands_suggestions branch from ae33263 to 6b6d9af Compare February 10, 2025 05:24
@krepysh krepysh marked this pull request as ready for review February 10, 2025 05:29
@krepysh krepysh force-pushed the 1021_add_commands_suggestions branch from 6b6d9af to ed400b8 Compare March 7, 2025 10:48
Argument(
names=("suggestions", "s"),
kind=bool,
default=True,
Copy link
Author

@krepysh krepysh Mar 7, 2025

Choose a reason for hiding this comment

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

Is it possible to default here to True?

If someone wanted to disable new feature, it is possible with --no-suggestions flag I guess.

krepysh added 2 commits March 7, 2025 16:25
This change prevent program from crashing, when ParseError is raised due
to processing core args
@krepysh krepysh force-pushed the 1021_add_commands_suggestions branch from ed400b8 to 9455d8a Compare March 7, 2025 17:39
@krepysh krepysh force-pushed the 1021_add_commands_suggestions branch 5 times, most recently from 09ddae8 to 44ef6ce Compare March 7, 2025 20:17
@krepysh krepysh force-pushed the 1021_add_commands_suggestions branch from 44ef6ce to 1ca1904 Compare March 7, 2025 20:21
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.

1 participant