From d3b5d7f6ed706ebf0c2d11327c81aad9b25cbe80 Mon Sep 17 00:00:00 2001 From: PetreM Date: Wed, 9 Oct 2024 13:35:38 +0300 Subject: [PATCH] Fix BinaryName initialization from args (#1174) Fixes an issue with `completion bash` where the command name is not present in the completion output. --- cmd/root.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index 35d266356..d94d5c847 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -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. @@ -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