Skip to content

Commit

Permalink
Updates from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
dearchap committed Nov 2, 2024
1 parent 0d30b84 commit 8c6801f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
6 changes: 5 additions & 1 deletion args.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,11 @@ type Argument interface {
}

// AnyArguments to differentiate between no arguments(nil) vs aleast one
var AnyArguments = []Argument{nil}
var AnyArguments = []Argument{
&StringArg{
Max: -1,
},
}

type ArgumentBase[T any, C any, VC ValueCreator[T, C]] struct {
Name string `json:"name"` // the name of this argument
Expand Down
2 changes: 1 addition & 1 deletion examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ func ExampleCommand_Run_commandHelp() {
}

func ExampleCommand_Run_noAction() {
cmd := &cli.Command{Name: "greet"} //, Arguments: cli.AnyArguments}
cmd := &cli.Command{Name: "greet"}

// Simulate the command line arguments
os.Args = []string{"greet"}
Expand Down
6 changes: 5 additions & 1 deletion godoc-current.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ var (
SuggestCommand SuggestCommandFunc = suggestCommand
SuggestDidYouMeanTemplate string = suggestDidYouMeanTemplate
)
var AnyArguments = []Argument{nil}
var AnyArguments = []Argument{
&StringArg{
Max: -1,
},
}
AnyArguments to differentiate between no arguments(nil) vs aleast one

var CommandHelpTemplate = `NAME:
Expand Down
11 changes: 9 additions & 2 deletions testdata/godoc-v3.x.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ var (
SuggestCommand SuggestCommandFunc = suggestCommand
SuggestDidYouMeanTemplate string = suggestDidYouMeanTemplate
)
var AnyArguments = []Argument{
&StringArg{
Max: -1,
},
}
AnyArguments to differentiate between no arguments(nil) vs aleast one

var CommandHelpTemplate = `NAME:
{{template "helpNameTemplate" .}}

Expand Down Expand Up @@ -84,7 +91,7 @@ var RootCommandHelpTemplate = `NAME:
{{template "helpNameTemplate" .}}

USAGE:
{{if .UsageText}}{{wrap .UsageText 3}}{{else}}{{.FullName}} {{if .VisibleFlags}}[global options]{{end}}{{if .VisibleCommands}} [command [command options]]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}{{end}}{{if .Version}}{{if not .HideVersion}}
{{if .UsageText}}{{wrap .UsageText 3}}{{else}}{{.FullName}} {{if .VisibleFlags}}[global options]{{end}}{{if .VisibleCommands}} [command [command options]]{{end}}{{if .ArgsUsage}} {{.ArgsUsage}}{{else}}{{if .Arguments}} [arguments...]{{end}}{{end}}{{end}}{{if .Version}}{{if not .HideVersion}}

VERSION:
{{.Version}}{{end}}{{end}}{{if .Description}}
Expand Down Expand Up @@ -112,7 +119,7 @@ var SubcommandHelpTemplate = `NAME:
{{template "helpNameTemplate" .}}

USAGE:
{{if .UsageText}}{{wrap .UsageText 3}}{{else}}{{.FullName}} {{if .VisibleCommands}}[command [command options]] {{end}}{{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}{{end}}{{if .Category}}
{{if .UsageText}}{{wrap .UsageText 3}}{{else}}{{.FullName}}{{if .VisibleCommands}} [command [command options]] {{end}}{{if .ArgsUsage}} {{.ArgsUsage}}{{else}}{{if .Arguments}} [arguments...]{{end}}{{end}}{{end}}{{if .Category}}

CATEGORY:
{{.Category}}{{end}}{{if .Description}}
Expand Down

0 comments on commit 8c6801f

Please sign in to comment.