Skip to content

Commit 02119df

Browse files
authored
fix: shell completion use exec's actual name (#4015)
1 parent 983d6a9 commit 02119df

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

internal/command/root/root.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ package root
33

44
import (
55
"context"
6+
"log"
7+
"os"
8+
"path/filepath"
69

710
"github.com/kr/text"
811
"github.com/olekukonko/tablewriter"
@@ -77,7 +80,16 @@ func New() *cobra.Command {
7780
short = "The Fly.io command line interface"
7881
)
7982

80-
root := command.New("fly", short, long, run)
83+
exePath, err := os.Executable()
84+
var exe string
85+
if err != nil {
86+
log.Printf("WARN: failed to find executable, error=%q", err)
87+
exe = "fly"
88+
} else {
89+
exe = filepath.Base(exePath)
90+
}
91+
92+
root := command.New(exe, short, long, run)
8193
root.PersistentPreRun = func(cmd *cobra.Command, args []string) {
8294
cmd.SilenceUsage = true
8395
cmd.SilenceErrors = true

0 commit comments

Comments
 (0)