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

Remove .exe suffix if any in completion #24966

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion cmd/podman/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ Options:

var (
rootCmd = &cobra.Command{
Use: filepath.Base(os.Args[0]) + " [options]",
// In shell completion, there is `.exe` suffix on Windows.
// This does not provide the same experience across platforms
// and was mentioned in [#16499](https://github.com/containers/podman/issues/16499).
Use: strings.TrimSuffix(filepath.Base(os.Args[0]), ".exe") + " [options]",
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a comment here why .exe is trimmed and add a link to the issue.
If the line is moved or edited again it may no longer be easy to find in the git history.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment and links to issue and pr are added.
I also added description to the commit message.

Long: "Manage pods, containers and images",
SilenceUsage: true,
SilenceErrors: true,
Expand Down
11 changes: 11 additions & 0 deletions pkg/machine/e2e/config_help_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package e2e_test

type helpMachine struct {
cmd []string
}

func (i *helpMachine) buildCmd(m *machineTestBuilder) []string {
cmd := []string{"help"}
i.cmd = cmd
return cmd
}
23 changes: 23 additions & 0 deletions pkg/machine/e2e/help_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package e2e_test

import (
"regexp"
"slices"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gexec"
)

var _ = Describe("podman help", func() {
It("podman usage base command is podman or podman-remote, without extension ", func() {
helpSession, err := mb.setCmd(new(helpMachine)).run()
Expect(err).NotTo(HaveOccurred())
Expect(helpSession).Should(Exit(0))

// Verify `.exe` suffix doesn't present in the usage command string
helpMessages := helpSession.outputToStringSlice()
usageCmdIndex := slices.IndexFunc(helpMessages, func(helpMessage string) bool { return helpMessage == "Usage:" }) + 1
Expect(regexp.MustCompile(`\w\.exe\b`).MatchString(helpMessages[usageCmdIndex])).Should(BeFalse())
})
})
Loading