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

Test commandName subcommand order #12535

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

maxproske
Copy link
Contributor

@maxproske maxproske commented Feb 7, 2025

What I did

Previously, when the root CLI span cli/<cmd> was named, the subcommand path was returned in reverse alphabetical order instead of CLI order, contradicting the comment above the function.

edit: Reverted to the original sorting and updated test and function comment to clarify intended behaviour.

Before:

docker compose alpha watch -> [watch, alpha]

After:

docker compose alpha watch -> [alpha, watch]

(not mandatory) A picture of a cute animal, if possible in relation to what you did

w460

@maxproske maxproske requested a review from a team as a code owner February 7, 2025 06:28
@maxproske maxproske requested review from ndeloof and glours February 7, 2025 06:28
@glours
Copy link
Contributor

glours commented Feb 7, 2025

Hi @maxproske
Thanks for this proposal, I think that will potentially affect the metrics history we have, @ndeloof can you double check please?

@maxproske
Copy link
Contributor Author

No worries, let me know if the original sorting is desired, and I'll update the comment/test accordingly.

@@ -130,7 +129,9 @@ func commandName(cmd *cobra.Command) []string {
}
name = append(name, c.Name())
}
sort.Sort(sort.Reverse(sort.StringSlice(name)))
for i, j := 0, len(name)-1; i < j; i, j = i+1, j-1 {
Copy link
Contributor

Choose a reason for hiding this comment

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

can use slices.Reverse - which basically does the same, but will make the intent obvious

@ndeloof
Copy link
Contributor

ndeloof commented Feb 9, 2025

I indeed need to check the impact on usage metrics

Signed-off-by: Max Proske <max@mproske.com>
@maxproske maxproske force-pushed the feature/span-cli-order branch from a61163b to c52c3b3 Compare February 10, 2025 16:20
@maxproske maxproske changed the title Fix commandName to return subcommands in CLI order Test commandName subcommand order Feb 10, 2025
@maxproske maxproske requested a review from ndeloof February 10, 2025 16:21
@ndeloof ndeloof enabled auto-merge (rebase) February 10, 2025 16:22
@ndeloof ndeloof disabled auto-merge February 10, 2025 16:22
@maxproske
Copy link
Contributor Author

Reverted to the original sorting, and updated the tests/comment to match intended behaviour.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants