Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CLI: do not provide command hints during tab-completion (#5012)
The `verdi` command uses a custom `Group` subclass that overrides the `get_command` method to provide some additional information in case the provided command name does not exist. These hints should help the user spot potential typos by giving a list of existing commands with similar names. However, this feature was also being triggered during tab-completion. For example, typing `verdi comput list` followed by activating tab-completion would result in the error being displayed since `comput` is not a valid command. In this case, one does not want to display the error message with hint at all. The tricky part is that there is no canonical way to distinguish between a normal command execution and a tab-completion event. The best bet is to use the `resilient_parsing` attribute on the `Context` which is set to `True` during tab-completion. Although this attribute was introduced into `click` directly to support auto-completion functionality, the problem is that this is not the only use case for which this flag can be set. It is therefore possible that there is some code path where this flag is set to `True` but it does not actually correspond to a tab-completion event. For now there doesn't seem to be a better solution though and in most cases this approach should work. Cherry-pick: 8e763bb
- Loading branch information