Skip to content

Commit

Permalink
Changing version command text information
Browse files Browse the repository at this point in the history
  • Loading branch information
kenshaw committed Dec 22, 2024
1 parent 2249267 commit e25aeaa
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions defs.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@ func AddHelpFlag(cmd *Command) error {

// NewVersion adds a `version` sub command to the command.
func NewVersion(cmd *Command, opts ...Option) error {
name := cmd.RootName()
return cmd.Sub(prepend(
opts,
Usage(text.VersionCommandName, text.VersionCommandUsage),
Banner(fmt.Sprintf(text.VersionCommandBanner, cmd.RootName())),
Usage(text.VersionCommandName, fmt.Sprintf(text.VersionCommandUsage, name)),
Banner(fmt.Sprintf(text.VersionCommandBanner, name)),
Special(`version`),
Exec(func(ctx context.Context) error {
c, _ := Ctx(ctx)
Expand Down
2 changes: 1 addition & 1 deletion example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ func Example_sections() {
//
// Available Commands:
// completion generate completion script for a specified shell
// version show version, then exit
// version show tree version information
//
// Primary commands:
// help show help for any command
Expand Down
2 changes: 1 addition & 1 deletion text/text.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ var (
// VersionCommandName is the `version` command name.
VersionCommandName = `version`
// VersionCommandUsage is the `version` command description.
VersionCommandUsage = `show version, then exit`
VersionCommandUsage = `show %s version information`
// VersionCommandBanner is the `version` command banner.
VersionCommandBanner = `Shows the %s version and exits.`
// VersionFlagName is the `--version` flag name.
Expand Down

0 comments on commit e25aeaa

Please sign in to comment.