diff --git a/internal/homesick/cli/cli.go b/internal/homesick/cli/cli.go index 9afef8e..0cd516f 100644 --- a/internal/homesick/cli/cli.go +++ b/internal/homesick/cli/cli.go @@ -5,6 +5,7 @@ import ( "fmt" "io" "os" + "path/filepath" "strings" "git.hrafn.xyz/aether/gosick/internal/homesick/core" @@ -21,8 +22,8 @@ func Run(args []string, stdout io.Writer, stderr io.Writer) int { parser, err := kong.New( &cliModel{}, - kong.Name("homesick"), - kong.Description("Go scaffold"), + kong.Name(programName()), + kong.Description("Your home is your castle. Don't leave your precious dotfiles behind."), kong.Writers(stdout, stderr), kong.Exit(func(int) {}), kong.ConfigureHelp(kong.HelpOptions{Compact: true}), @@ -192,6 +193,16 @@ func defaultCastle(castle string) string { return castle } +func programName() string { + if len(os.Args) > 0 { + if name := strings.TrimSpace(filepath.Base(os.Args[0])); name != "" { + return name + } + } + + return "gosick" +} + func normalizeArgs(args []string) []string { if len(args) == 0 { return []string{"--help"} diff --git a/internal/homesick/cli/cli_test.go b/internal/homesick/cli/cli_test.go index cd97a4e..3fa5d51 100644 --- a/internal/homesick/cli/cli_test.go +++ b/internal/homesick/cli/cli_test.go @@ -59,4 +59,18 @@ func (s *CLISuite) TestRun_CloneSubcommandHelp() { require.Contains(s.T(), s.stdout.String(), "clone") require.Contains(s.T(), s.stdout.String(), "URI") require.Empty(s.T(), s.stderr.String()) -} \ No newline at end of file +} + +func (s *CLISuite) TestRun_Help_UsesProgramNameAndDescription() { + originalArgs := os.Args + s.T().Cleanup(func() { os.Args = originalArgs }) + os.Args = []string{"gosick"} + + exitCode := cli.Run([]string{"--help"}, s.stdout, s.stderr) + + require.Equal(s.T(), 0, exitCode) + require.Contains(s.T(), s.stdout.String(), "Usage: gosick") + require.NotContains(s.T(), s.stdout.String(), "Usage: homesick") + require.Contains(s.T(), s.stdout.String(), "precious dotfiles") + require.Empty(s.T(), s.stderr.String()) +}