Skip to content

Commit d3b5d7f

Browse files
authored
Fix BinaryName initialization from args (#1174)
Fixes an issue with `completion bash` where the command name is not present in the completion output.
1 parent 0706bdb commit d3b5d7f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

cmd/root.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414

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

44+
func getCommandName() string {
45+
return os.Args[0]
46+
}
47+
4448
func init() {
45-
BinaryName = os.Args[0]
49+
BinaryName = getCommandName()
4650
config.SetDefaultDirName(BinaryName)
4751
Out = os.Stdout
4852
Err = os.Stderr

0 commit comments

Comments
 (0)