Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: urfave/cli
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v2.23.7
Choose a base ref
...
head repository: urfave/cli
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v2.23.8
Choose a head ref
  • 3 commits
  • 7 files changed
  • 1 contributor

Commits on Dec 30, 2022

  1. Verified

    This commit was signed with the committer’s verified signature.
    kzaher Krunoslav Zaher
    Copy the full SHA
    0904253 View commit details
  2. Fix wording

    dearchap committed Dec 30, 2022
    Copy the full SHA
    ba2a124 View commit details

Commits on Jan 6, 2023

  1. Merge pull request #1633 from dearchap/issue_1277

    Fix:(issue_1277) Remove default text for version/help flags
    dearchap authored Jan 6, 2023
    Copy the full SHA
    c891d79 View commit details
Showing with 47 additions and 31 deletions.
  1. +5 −5 app_test.go
  2. +2 −0 flag-spec.yaml
  3. +15 −8 flag.go
  4. +10 −6 godoc-current.txt
  5. +3 −6 help_test.go
  6. +10 −6 testdata/godoc-v2.x.txt
  7. +2 −0 zz_generated.flags.go
10 changes: 5 additions & 5 deletions app_test.go
Original file line number Diff line number Diff line change
@@ -145,8 +145,8 @@ func ExampleApp_Run_appHelp() {
//
// GLOBAL OPTIONS:
// --name value a name to say (default: "bob")
// --help, -h show help (default: false)
// --version, -v print the version (default: false)
// --help, -h show help
// --version, -v print the version
}

func ExampleApp_Run_commandHelp() {
@@ -183,7 +183,7 @@ func ExampleApp_Run_commandHelp() {
// This is how we describe describeit the function
//
// OPTIONS:
// --help, -h show help (default: false)
// --help, -h show help
}

func ExampleApp_Run_noAction() {
@@ -201,7 +201,7 @@ func ExampleApp_Run_noAction() {
// help, h Shows a list of commands or help for one command
//
// GLOBAL OPTIONS:
// --help, -h show help (default: false)
// --help, -h show help
}

func ExampleApp_Run_subcommandNoAction() {
@@ -228,7 +228,7 @@ func ExampleApp_Run_subcommandNoAction() {
// This is how we describe describeit the function
//
// OPTIONS:
// --help, -h show help (default: false)
// --help, -h show help

}

2 changes: 2 additions & 0 deletions flag-spec.yaml
Original file line number Diff line number Diff line change
@@ -7,6 +7,8 @@ flag_types:
- name: Count
type: int
pointer: true
- name: DisableDefaultText
type: bool
- name: Action
type: "func(*Context, bool) error"
float64:
23 changes: 15 additions & 8 deletions flag.go
Original file line number Diff line number Diff line change
@@ -34,18 +34,20 @@ var BashCompletionFlag Flag = &BoolFlag{

// VersionFlag prints the version for the application
var VersionFlag Flag = &BoolFlag{
Name: "version",
Aliases: []string{"v"},
Usage: "print the version",
Name: "version",
Aliases: []string{"v"},
Usage: "print the version",
DisableDefaultText: true,
}

// HelpFlag prints the help for all commands and subcommands.
// Set to nil to disable the flag. The subcommand
// will still be added unless HideHelp or HideHelpCommand is set to true.
var HelpFlag Flag = &BoolFlag{
Name: "help",
Aliases: []string{"h"},
Usage: "show help",
Name: "help",
Aliases: []string{"h"},
Usage: "show help",
DisableDefaultText: true,
}

// FlagStringer converts a flag definition to a string. This is used by help
@@ -337,8 +339,13 @@ func stringifyFlag(f Flag) string {

defaultValueString := ""

if s := df.GetDefaultText(); s != "" {
defaultValueString = fmt.Sprintf(formatDefault("%s"), s)
// set default text for all flags except bool flags
// for bool flags display default text if DisableDefaultText is not
// set
if bf, ok := f.(*BoolFlag); !ok || !bf.DisableDefaultText {
if s := df.GetDefaultText(); s != "" {
defaultValueString = fmt.Sprintf(formatDefault("%s"), s)
}
}

usageWithDefault := strings.TrimSpace(usage + defaultValueString)
16 changes: 10 additions & 6 deletions godoc-current.txt
Original file line number Diff line number Diff line change
@@ -455,6 +455,8 @@ type BoolFlag struct {

Count *int

DisableDefaultText bool

Action func(*Context, bool) error
// Has unexported fields.
}
@@ -881,18 +883,20 @@ var BashCompletionFlag Flag = &BoolFlag{
BashCompletionFlag enables bash-completion for all commands and subcommands

var HelpFlag Flag = &BoolFlag{
Name: "help",
Aliases: []string{"h"},
Usage: "show help",
Name: "help",
Aliases: []string{"h"},
Usage: "show help",
DisableDefaultText: true,
}
HelpFlag prints the help for all commands and subcommands. Set to nil to
disable the flag. The subcommand will still be added unless HideHelp or
HideHelpCommand is set to true.

var VersionFlag Flag = &BoolFlag{
Name: "version",
Aliases: []string{"v"},
Usage: "print the version",
Name: "version",
Aliases: []string{"v"},
Usage: "print the version",
DisableDefaultText: true,
}
VersionFlag prints the version for the application

9 changes: 3 additions & 6 deletions help_test.go
Original file line number Diff line number Diff line change
@@ -1366,8 +1366,7 @@ DESCRIPTION:
case
OPTIONS:
--help, -h show help
(default: false)
--help, -h show help
`

if output.String() != expected {
@@ -1436,8 +1435,7 @@ USAGE:
even more
OPTIONS:
--help, -h show help
(default: false)
--help, -h show help
`

if output.String() != expected {
@@ -1514,8 +1512,7 @@ USAGE:
OPTIONS:
--test-f value my test
usage
--help, -h show help
(default: false)
--help, -h show help
`

if output.String() != expected {
16 changes: 10 additions & 6 deletions testdata/godoc-v2.x.txt
Original file line number Diff line number Diff line change
@@ -455,6 +455,8 @@ type BoolFlag struct {

Count *int

DisableDefaultText bool

Action func(*Context, bool) error
// Has unexported fields.
}
@@ -881,18 +883,20 @@ var BashCompletionFlag Flag = &BoolFlag{
BashCompletionFlag enables bash-completion for all commands and subcommands

var HelpFlag Flag = &BoolFlag{
Name: "help",
Aliases: []string{"h"},
Usage: "show help",
Name: "help",
Aliases: []string{"h"},
Usage: "show help",
DisableDefaultText: true,
}
HelpFlag prints the help for all commands and subcommands. Set to nil to
disable the flag. The subcommand will still be added unless HideHelp or
HideHelpCommand is set to true.

var VersionFlag Flag = &BoolFlag{
Name: "version",
Aliases: []string{"v"},
Usage: "print the version",
Name: "version",
Aliases: []string{"v"},
Usage: "print the version",
DisableDefaultText: true,
}
VersionFlag prints the version for the application

2 changes: 2 additions & 0 deletions zz_generated.flags.go
Original file line number Diff line number Diff line change
@@ -448,6 +448,8 @@ type BoolFlag struct {

Count *int

DisableDefaultText bool

Action func(*Context, bool) error
}