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 a validation and suggestions for incorrect subcommands #10

Open
talis-fb opened this issue Jan 27, 2024 · 0 comments
Open

Add a validation and suggestions for incorrect subcommands #10

talis-fb opened this issue Jan 27, 2024 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers Medium Requires some effort and time

Comments

@talis-fb
Copy link
Owner

talis-fb commented Jan 27, 2024

The current behavior of the treq command allows the execution of a request when a subcommand is omitted, potentially leading to confusion. For example, both treq GET url.com and treq url.com execute the same command. However, if the user mistypes a subcommand (e.g., treq GE url.com), it interprets the mistyped text as the URL and additional parameters, submitting a GET request for http://GE and attempting to validate url.com as a Request item.

The proposal is to implement a command validator specifically for default command requests (no subcommand provided). This validator will check for potential mistyped subcommands. If the entered command closely resembles a valid subcommand, provide a helpful suggestion to the user before executing the command.

Expected Behavior:

  • Implement a command validator to identify potential mistyped subcommands for default command requests.
  • Provide suggestions for valid subcommands using string distance calculation (Levenshtein distance).
  • Optionally, continue execution only if the user confirms the suggested correction. (Consider implementing a flag like --no-confirm to skip the confirmation prompt and only display a warning.)

Additional Considerations:

  • Ensure that the string distance calculation is case-insensitive. For example, when a user types treq get or treq GEt, the recommendation to type GET should appear, regardless of the casing.
  • Provide a nice and clear output warning for this help.
  • Conduct thorough testing to verify the accurate of String distance algorithm
@talis-fb talis-fb added enhancement New feature or request good first issue Good for newcomers Medium Requires some effort and time labels Jan 27, 2024
@talis-fb talis-fb changed the title Add a command validator and suggestions for incorrect subcommands typing Add a command validator and suggestions for incorrect subcommands Jan 27, 2024
@talis-fb talis-fb changed the title Add a command validator and suggestions for incorrect subcommands Add a validation and suggestions for incorrect subcommands Jan 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers Medium Requires some effort and time
Projects
Status: No status
Development

No branches or pull requests

1 participant