feat: support shell completions in tedge cli#3332
feat: support shell completions in tedge cli#3332jarhodes314 merged 2 commits intothin-edge:mainfrom
tedge cli#3332Conversation
Codecov ReportAttention: Patch coverage is Additional details and impacted files📢 Thoughts on this report? Let us know! |
Robot Results
|
didier-wenzek
left a comment
There was a problem hiding this comment.
Testing this PR with zsh I noticed some weirdness, however overall completion is working nicely.
Completion on tedge config set is fantastic!
The weirdness seems to be due to the overly complicated argument logic of thin-edge.
- e.g.
--config-dir,--debug,--log-levelare never proposed for completion
| fn qos_completions() -> Vec<CompletionCandidate> { | ||
| vec![ | ||
| CompletionCandidate::new("0").help(Some("At most once".into())), | ||
| CompletionCandidate::new("1").help(Some("At least once".into())), | ||
| CompletionCandidate::new("2").help(Some("Exactly once".into())), | ||
| ] | ||
| } | ||
|
|
There was a problem hiding this comment.
Really nice
$ tedge mqtt pub --qos <TAB>
0 -- At most once
1 -- At least once
2 -- Exactly once
| #[clap(long = "output-path", global = true, value_hint = ValueHint::FilePath)] | ||
| output_path: Option<Utf8PathBuf>, |
There was a problem hiding this comment.
We might have to add this hint for other path (e.g. --config-dir ).
There was a problem hiding this comment.
Good point, I also need to make a modification to support the global arguments
There was a problem hiding this comment.
Added the hint and fixed the issue where the global arguments weren't completed
There was a problem hiding this comment.
Any chance to get the --log-level value also completed? e.g. tedge --log-level <TAB><TAB>
There was a problem hiding this comment.
Perfect, works as expected
Now fixed |
7a2c5b8 to
3e2332b
Compare
Signed-off-by: James Rhodes <james.rhodes@cumulocity.com>
3e2332b to
1cf7710
Compare
reubenmiller
left a comment
There was a problem hiding this comment.
Approving (from a UX point of view). Still wait for a Rust review.
Really nice addition. We can work out any packaging aspects in a follow up PR
didier-wenzek
left a comment
There was a problem hiding this comment.
Approved. Quickly and nicely done.
| /// This will infer the profile names from the various cloud configurations. | ||
| /// It would be significantly more complicated to try and do per-cloud | ||
| /// completions, and would likely provide no real value to anyone. |
There was a problem hiding this comment.
That seems reasonable.
Proposed changes
This adds shell completions (bash, zsh, fish) to the
tedgeCLI. It should be fairly self explanatory, and the documentation added in the PR should explain how you can enable the feature for testing locally.Types of changes
Paste Link to the issue
tedgeCLI #3331Checklist
cargo fmtas mentioned in CODING_GUIDELINEScargo clippyas mentioned in CODING_GUIDELINESFurther comments