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 shell completion #348

Merged
merged 22 commits into from
Sep 4, 2024
Merged

Add shell completion #348

merged 22 commits into from
Sep 4, 2024

Conversation

windsource
Copy link
Contributor

@windsource windsource commented Aug 9, 2024

This PR adds shell completion for static and dynamic parts using clap_complete.

Issues: #237

Definition of Done

The PR shall be merged only if all items mentioned in CONTRIBUTING.md have been followed. In case an item is not applicable as described, please provide a short explanation in the description.

@windsource
Copy link
Contributor Author

windsource commented Aug 9, 2024

Still missing:

  • Documentation
  • Dynamic completion

@windsource
Copy link
Contributor Author

The current version only works for static completions. To prepare for dynamic completions, the method as described in https://github.com/clap-rs/clap/pull/5586/files probably has to be used.

@windsource
Copy link
Contributor Author

Now this PR is prepared for dynamic completion as described in clap_complete::dynamic::ArgValueCompleterCopy. In there we need to query the server for available workloads.

@windsource
Copy link
Contributor Author

I started a discussion in clap-rs/clap#5677.

@windsource
Copy link
Contributor Author

The current version provides static completion. It also contains dynamic completion for the ank delete workload command and can be used for first evaluation. Then we need to decide, if we continue with using the ank command itself for dynamic completion or if there is a better way user Rust code in the closure instead.

@windsource
Copy link
Contributor Author

clap_complete with the features "unstable-dynamic" and "unstable-command" is really unstable for the time being. The ank code that compiles with clap_complete 4.5.14 does not compile when using 4.5.18 anymore. Maybe we should wait with merging this PR or also introduce a feature flag for the dynamic completion.

Before this change we were using 1.79.0 which less than required by
clap_complete 4.5.18.

Issue-Id: #237
@windsource
Copy link
Contributor Author

Currently the build fails as clippy complains about unused variables. This is a bug in clippy which exists in Rust 1.80.0 (current Rust version in dev container) and is fixed in Rust 1.80.1.
I will create a separate PR to create a dev container with Rust 1.80.1.

@windsource
Copy link
Contributor Author

Besides that, this PR is feature complete but lacks tests and also SWDD changes.

@windsource
Copy link
Contributor Author

Created bug report clap-rs/clap#5701.

@windsource
Copy link
Contributor Author

All done. Read for review.

ank/src/cli.rs Outdated Show resolved Hide resolved
doc/docs/usage/shell-completion.md Show resolved Hide resolved
Copy link
Contributor

@krucod3 krucod3 left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@krucod3 krucod3 merged commit 08d4db2 into main Sep 4, 2024
10 checks passed
@windsource windsource added the enhancement New feature or request. Issue will appear in the change log "Features" label Nov 7, 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. Issue will appear in the change log "Features" ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants