diff --git a/cmd/bursa/main.go b/cmd/bursa/main.go index b39a090..d18ab8b 100644 --- a/cmd/bursa/main.go +++ b/cmd/bursa/main.go @@ -24,11 +24,18 @@ import ( ) func main() { - fs := flag.NewFlagSet(os.Args[0], flag.ExitOnError) + var appName string + if os.Args == nil { + appName = "bursa" + } else { + appName = os.Args[0] + } + fs := flag.NewFlagSet(appName, flag.ExitOnError) fs.Usage = func() { fmt.Fprintf( flag.CommandLine.Output(), - "Usage: bursa [-h] [args]\n\nSubcommands:\n\n", + "Usage: %s [-h] [args]\n\nSubcommands:\n\n", + appName, ) fmt.Fprintf( flag.CommandLine.Output(), @@ -43,6 +50,10 @@ func main() { "run a terminal command", ) } + if os.Args == nil { + fs.Usage() + os.Exit(1) + } _ = fs.Parse(os.Args[1:]) // ignore parse errors // Load Config