Skip to content

Commit

Permalink
Fix BinaryName initialization from args (#1174)
Browse files Browse the repository at this point in the history
Fixes an issue with `completion bash` where the command name is not present
in the completion output.
  • Loading branch information
petrem authored Oct 9, 2024
1 parent 0706bdb commit d3b5d7f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (

// RootCmd represents the base command when called without any subcommands.
var RootCmd = &cobra.Command{
Use: BinaryName,
Use: getCommandName(),
Short: "A friendly command-line interface to Exercism.",
Long: `A command-line interface for Exercism.
Expand All @@ -41,8 +41,12 @@ func Execute() {
}
}

func getCommandName() string {
return os.Args[0]
}

func init() {
BinaryName = os.Args[0]
BinaryName = getCommandName()
config.SetDefaultDirName(BinaryName)
Out = os.Stdout
Err = os.Stderr
Expand Down

0 comments on commit d3b5d7f

Please sign in to comment.