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
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:
Additional Considerations:
treq get
ortreq GEt
, the recommendation to type GET should appear, regardless of the casing.