Skip to content

Commit 834a1c9

Browse files
Merge pull request #24966 from silver886/patch-2
Remove `.exe` suffix if any in completion
2 parents 31dd624 + a91aa36 commit 834a1c9

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

cmd/podman/root.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ Options:
6262

6363
var (
6464
rootCmd = &cobra.Command{
65-
Use: filepath.Base(os.Args[0]) + " [options]",
65+
// In shell completion, there is `.exe` suffix on Windows.
66+
// This does not provide the same experience across platforms
67+
// and was mentioned in [#16499](https://github.com/containers/podman/issues/16499).
68+
Use: strings.TrimSuffix(filepath.Base(os.Args[0]), ".exe") + " [options]",
6669
Long: "Manage pods, containers and images",
6770
SilenceUsage: true,
6871
SilenceErrors: true,

pkg/machine/e2e/config_help_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package e2e_test
2+
3+
type helpMachine struct {
4+
cmd []string
5+
}
6+
7+
func (i *helpMachine) buildCmd(m *machineTestBuilder) []string {
8+
cmd := []string{"help"}
9+
i.cmd = cmd
10+
return cmd
11+
}

pkg/machine/e2e/help_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package e2e_test
2+
3+
import (
4+
"regexp"
5+
"slices"
6+
7+
. "github.com/onsi/ginkgo/v2"
8+
. "github.com/onsi/gomega"
9+
. "github.com/onsi/gomega/gexec"
10+
)
11+
12+
var _ = Describe("podman help", func() {
13+
It("podman usage base command is podman or podman-remote, without extension ", func() {
14+
helpSession, err := mb.setCmd(new(helpMachine)).run()
15+
Expect(err).NotTo(HaveOccurred())
16+
Expect(helpSession).Should(Exit(0))
17+
18+
// Verify `.exe` suffix doesn't present in the usage command string
19+
helpMessages := helpSession.outputToStringSlice()
20+
usageCmdIndex := slices.IndexFunc(helpMessages, func(helpMessage string) bool { return helpMessage == "Usage:" }) + 1
21+
Expect(regexp.MustCompile(`\w\.exe\b`).MatchString(helpMessages[usageCmdIndex])).Should(BeFalse())
22+
})
23+
})

0 commit comments

Comments
 (0)