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 tests to shell completion #14512

Open
simondeziel opened this issue Nov 22, 2024 · 0 comments
Open

Add tests to shell completion #14512

simondeziel opened this issue Nov 22, 2024 · 0 comments
Labels
Improvement Improve to current situation

Comments

@simondeziel
Copy link
Member

The completion tooling we use supports __complete that serves as a debugging aid. This is handy as we can then walk through all the commands with completion enabled. Here's a quick example:

for command in $(lxc __complete "" | awk '/^[^:]/ {print $1}'); do
  # show all the actions
  lxc __complete $command ""
  # show all the flags
  lxc __complete $command --
done

Here's what it looks like for real:

$ lxc __complete warning ""
acknowledge	Acknowledge warning
delete	Delete warning
list	List warnings
show	Show warning
:4
Completion ended with directive: ShellCompDirectiveNoFileComp

$ lxc __complete warning --
--debug	Show all debug messages
--force-local	Force using the local unix socket
--help	Print help
--project	Override the source project``
--quiet	Don't show progress information
--sub-commands	Use with help or --help to view sub-commands
--verbose	Show all information messages
--version	Print version number
:4
Completion ended with directive: ShellCompDirectiveNoFileComp

Having a test walking into some of those commands+actions would improve the test coverage and provide an opportunity to check for the expected completion targets for some of them. Adding them all is probably not worth the time and maintenance trouble but having a few ones would be nice.

@tomponline tomponline added the Improvement Improve to current situation label Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Improvement Improve to current situation
Projects
None yet
Development

No branches or pull requests

2 participants