furiko-io / furiko

Kubernetes cron and batch job platform
https://furiko.io
Apache License 2.0
483 stars 21 forks source link

fix(cli): Use ShellCompDirectiveKeepOrder to preserve order in shell completions #132

Closed irvinlim closed 1 year ago

irvinlim commented 1 year ago

Fixes shell completion order not being preserved, which is fixed with spf13/cobra#1900.

image

In the above screenshot, note that completions should be sorted by CreationTimestamp; without the KeepOrder directive introduced in the cobra library, the completions would be sorted in lexicographical order in shells such as zsh by default (source):

The options placed in the array name take account of the group-name style, so matches are placed in a separate group where necessary. The group normally has its elements sorted (by passing the option -J to compadd), but if an option starting with ‘-V’, ‘-J’, ‘-1’, or ‘-2’ is passed to _description, that option will be included in the array. Hence it is possible for the completion group to be unsorted by giving the option ‘-V’, ‘-1V’, or ‘-2V’.

codecov[bot] commented 1 year ago

Codecov Report

Base: 70.80% // Head: 70.80% // No change to project coverage :thumbsup:

Coverage data is based on head (c61a39f) compared to base (1ec355a). Patch coverage: 50.00% of modified lines in pull request are covered.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #132 +/- ## ======================================= Coverage 70.80% 70.80% ======================================= Files 206 206 Lines 10692 10692 ======================================= Hits 7571 7571 Misses 2726 2726 Partials 395 395 ``` | [Impacted Files](https://codecov.io/gh/furiko-io/furiko/pull/132?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=furiko-io) | Coverage Δ | | |---|---|---| | [pkg/cli/completion/completion.go](https://codecov.io/gh/furiko-io/furiko/pull/132?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=furiko-io#diff-cGtnL2NsaS9jb21wbGV0aW9uL2NvbXBsZXRpb24uZ28=) | `37.77% <50.00%> (ø)` | | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=furiko-io). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=furiko-io)

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.