Skip to content

Commit

Permalink
fix: shell completion use exec's actual name (#4015)
Browse files Browse the repository at this point in the history
  • Loading branch information
zuisong authored Oct 22, 2024
1 parent 983d6a9 commit 02119df
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion internal/command/root/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ package root

import (
"context"
"log"
"os"
"path/filepath"

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

root := command.New("fly", short, long, run)
exePath, err := os.Executable()
var exe string
if err != nil {
log.Printf("WARN: failed to find executable, error=%q", err)
exe = "fly"
} else {
exe = filepath.Base(exePath)
}

root := command.New(exe, short, long, run)
root.PersistentPreRun = func(cmd *cobra.Command, args []string) {
cmd.SilenceUsage = true
cmd.SilenceErrors = true
Expand Down

0 comments on commit 02119df

Please sign in to comment.