Skip to content

Commit

Permalink
fix: replace appname in CLI help
Browse files Browse the repository at this point in the history
  • Loading branch information
szkiba committed Aug 1, 2024
1 parent 66c5340 commit 04c0f89
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"log/slog"
"os"
"os/signal"
"strings"
"time"

"github.com/briandowns/spinner"
Expand Down Expand Up @@ -36,13 +37,16 @@ func initLogging(app string) *slog.LevelVar {
}

func main() {
runCmd(newCmd(os.Args[1:], initLogging(appname))) //nolint:forbidigo
runCmd(newCmd(appname, os.Args[1:], initLogging(appname))) //nolint:forbidigo
}

func newCmd(args []string, levelVar *slog.LevelVar) *cobra.Command {
func newCmd(appname string, args []string, levelVar *slog.LevelVar) *cobra.Command {
cmd := cmd.New(levelVar)
cmd.Version = version

cmd.Use = strings.ReplaceAll(cmd.Use, "k6exec", appname)
cmd.Long = strings.ReplaceAll(cmd.Long, "k6exec", appname)

if len(args) == 1 && (args[0] == "-h" || args[0] == "--help") {
args[0] = "help"
}
Expand Down

0 comments on commit 04c0f89

Please sign in to comment.