Skip to content

Commit de88ce6

Browse files
authored
Merge branch 'main' into issue-urfave#2145
2 parents 695e6b5 + 9cd5d9c commit de88ce6

File tree

6 files changed

+37
-30
lines changed

6 files changed

+37
-30
lines changed

docs/v3/examples/arguments/advanced.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ search:
77

88
The [Basics] showed how to access arguments for a command. They are all retrieved as strings which is fine
99
but it we need to say get integers or timestamps the user would have to convert from string to desired type.
10-
To ease the burden on users the `cli` library offers predefined `{Type}Arg` and `{Type}Args` structure to faciliate this
10+
To ease the burden on users the `cli` library offers predefined `{Type}Arg` and `{Type}Args` structure to faciliate this.
1111
The value of the argument can be retrieved using the `command.{Type}Arg()` function. For e.g
1212

1313
<!-- {
@@ -152,9 +152,9 @@ func main() {
152152

153153
Some things to note about multi value arguments
154154

155-
1. They are of `{Type}Args` type rather than `{Type}Arg` to differentiate them from single value arguments
156-
2. The `Max` field needs to be defined to a non zero value without which it cannot be parsed
157-
3. `Max` field value needs to be greater than the `Min` field value
155+
1. They are of `{Type}Args` type rather than `{Type}Arg` to differentiate them from single value arguments.
156+
2. The `Max` field needs to be defined to a non zero value without which it cannot be parsed.
157+
3. `Max` field value needs to be greater than the `Min` field value.
158158

159159
As with single value args the destination field can be set
160160

@@ -221,4 +221,4 @@ the following to the end of the Arguments slice and retrieve them as a slice
221221
&StringArgs{
222222
Max: -1,
223223
},
224-
```
224+
```

docs/v3/examples/completions/customizations.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ search:
55
boost: 2
66
---
77

8-
If default completion isnt sufficient additional customizations are available
8+
If default completion isn't sufficient additional customizations are available
99

1010
- custom auto-completion
1111
- customizing completion command

docs/v3/examples/full-api-example.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ func main() {
144144
&cli.FloatFlag{Name: "howmuch"},
145145
&cli.IntFlag{Name: "longdistance", Validator: func (t int) error {
146146
if t < 10 {
147-
return fmt.Errorf("10 miles isnt long distance!!!!")
147+
return fmt.Errorf("10 miles isn't long distance!!!!")
148148
}
149149
return nil
150150
}},

godoc-current.txt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,15 @@ COPYRIGHT:
131131
cli.go uses text/template to render templates. You can render custom help
132132
text by setting this variable.
133133

134+
var ShowAppHelp = showAppHelp
135+
ShowAppHelp is an action that displays the help
136+
137+
var ShowCommandHelp = showCommandHelp
138+
ShowCommandHelp prints help for the given command
139+
140+
var ShowSubcommandHelp = showSubcommandHelp
141+
ShowSubcommandHelp prints help for the given subcommand
142+
134143
var SubcommandHelpTemplate = `NAME:
135144
{{template "helpNameTemplate" .}}
136145

@@ -195,22 +204,13 @@ func HandleExitCoder(err error)
195204

196205
This function is the default error-handling behavior for an App.
197206

198-
func ShowAppHelp(cmd *Command) error
199-
ShowAppHelp is an action that displays the help.
200-
201207
func ShowAppHelpAndExit(cmd *Command, exitCode int)
202208
ShowAppHelpAndExit - Prints the list of subcommands for the app and exits
203209
with exit code.
204210

205-
func ShowCommandHelp(ctx context.Context, cmd *Command, commandName string) error
206-
ShowCommandHelp prints help for the given command
207-
208211
func ShowCommandHelpAndExit(ctx context.Context, cmd *Command, command string, code int)
209212
ShowCommandHelpAndExit - exits with code after showing help
210213

211-
func ShowSubcommandHelp(cmd *Command) error
212-
ShowSubcommandHelp prints help for the given subcommand
213-
214214
func ShowSubcommandHelpAndExit(cmd *Command, exitCode int)
215215
ShowSubcommandHelpAndExit - Prints help for the given subcommand and exits
216216
with exit code.

help.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@ var HelpPrinterCustom helpPrinterCustom = printHelpCustom
4444
// VersionPrinter prints the version for the App
4545
var VersionPrinter = printVersion
4646

47+
// ShowAppHelp is an action that displays the help
48+
var ShowAppHelp = showAppHelp
49+
50+
// ShowCommandHelp prints help for the given command
51+
var ShowCommandHelp = showCommandHelp
52+
53+
// ShowSubcommandHelp prints help for the given subcommand
54+
var ShowSubcommandHelp = showSubcommandHelp
55+
4756
func buildHelpCommand(withAction bool) *Command {
4857
cmd := &Command{
4958
Name: helpName,
@@ -131,7 +140,7 @@ func ShowAppHelpAndExit(cmd *Command, exitCode int) {
131140
}
132141

133142
// ShowAppHelp is an action that displays the help.
134-
func ShowAppHelp(cmd *Command) error {
143+
func showAppHelp(cmd *Command) error {
135144
tmpl := cmd.CustomRootCommandHelpTemplate
136145
if tmpl == "" {
137146
tracef("using RootCommandHelpTemplate")
@@ -270,8 +279,7 @@ func ShowCommandHelpAndExit(ctx context.Context, cmd *Command, command string, c
270279
os.Exit(code)
271280
}
272281

273-
// ShowCommandHelp prints help for the given command
274-
func ShowCommandHelp(ctx context.Context, cmd *Command, commandName string) error {
282+
func showCommandHelp(ctx context.Context, cmd *Command, commandName string) error {
275283
for _, subCmd := range cmd.Commands {
276284
if !subCmd.HasName(commandName) {
277285
continue
@@ -322,8 +330,7 @@ func ShowSubcommandHelpAndExit(cmd *Command, exitCode int) {
322330
os.Exit(exitCode)
323331
}
324332

325-
// ShowSubcommandHelp prints help for the given subcommand
326-
func ShowSubcommandHelp(cmd *Command) error {
333+
func showSubcommandHelp(cmd *Command) error {
327334
HelpPrinter(cmd.Root().Writer, SubcommandHelpTemplate, cmd)
328335
return nil
329336
}

testdata/godoc-v3.x.txt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,15 @@ COPYRIGHT:
131131
cli.go uses text/template to render templates. You can render custom help
132132
text by setting this variable.
133133

134+
var ShowAppHelp = showAppHelp
135+
ShowAppHelp is an action that displays the help
136+
137+
var ShowCommandHelp = showCommandHelp
138+
ShowCommandHelp prints help for the given command
139+
140+
var ShowSubcommandHelp = showSubcommandHelp
141+
ShowSubcommandHelp prints help for the given subcommand
142+
134143
var SubcommandHelpTemplate = `NAME:
135144
{{template "helpNameTemplate" .}}
136145

@@ -195,22 +204,13 @@ func HandleExitCoder(err error)
195204

196205
This function is the default error-handling behavior for an App.
197206

198-
func ShowAppHelp(cmd *Command) error
199-
ShowAppHelp is an action that displays the help.
200-
201207
func ShowAppHelpAndExit(cmd *Command, exitCode int)
202208
ShowAppHelpAndExit - Prints the list of subcommands for the app and exits
203209
with exit code.
204210

205-
func ShowCommandHelp(ctx context.Context, cmd *Command, commandName string) error
206-
ShowCommandHelp prints help for the given command
207-
208211
func ShowCommandHelpAndExit(ctx context.Context, cmd *Command, command string, code int)
209212
ShowCommandHelpAndExit - exits with code after showing help
210213

211-
func ShowSubcommandHelp(cmd *Command) error
212-
ShowSubcommandHelp prints help for the given subcommand
213-
214214
func ShowSubcommandHelpAndExit(cmd *Command, exitCode int)
215215
ShowSubcommandHelpAndExit - Prints help for the given subcommand and exits
216216
with exit code.

0 commit comments

Comments
 (0)