Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions command.go
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,8 @@ func defaultHelp(cmd *Command) error {
writePositionalArgs(cmd, s)
} else {
// We have no named arguments so do the best we can
// TODO(@FollowTheProcess): Can we detect if cli.NoArgs was used in which case
// omit this
s.WriteString("ARGS...")
}
} else {
Expand Down
Binary file modified docs/img/namedargs.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/img/quickstart.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/img/subcommands.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 3 additions & 18 deletions examples/subcommands/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

func BuildCLI() (*cli.Command, error) {
demo, err := cli.New(
return cli.New(
"demo",
cli.Short("An example CLI to demonstrate the library and play with it for real."),
cli.Version("dev"),
Expand All @@ -20,11 +20,6 @@ func BuildCLI() (*cli.Command, error) {
cli.Allow(cli.NoArgs()),
cli.SubCommands(buildSayCommand, buildDoCommand),
)
if err != nil {
return nil, err
}

return demo, nil
}

type sayOptions struct {
Expand All @@ -35,7 +30,7 @@ type sayOptions struct {

func buildSayCommand() (*cli.Command, error) {
var options sayOptions
say, err := cli.New(
return cli.New(
"say",
cli.Short("Print a message"),
cli.Example("Say a well known phrase", "demo say hello world"),
Expand All @@ -45,11 +40,6 @@ func buildSayCommand() (*cli.Command, error) {
cli.Flag(&options.count, "count", 'c', 0, "Count the things"),
cli.Flag(&options.thing, "thing", 't', "", "Name of the thing"),
)
if err != nil {
return nil, err
}

return say, nil
}

type doOptions struct {
Expand All @@ -61,7 +51,7 @@ type doOptions struct {

func buildDoCommand() (*cli.Command, error) {
var options doOptions
do, err := cli.New(
return cli.New(
"do",
cli.Short("Do a thing"),
cli.Example("Do something", "demo do something --fast"),
Expand All @@ -74,11 +64,6 @@ func buildDoCommand() (*cli.Command, error) {
cli.Flag(&options.duration, "duration", 'd', 1*time.Second, "Do the thing for a specific duration"),
cli.Run(runDo(&options)),
)
if err != nil {
return nil, err
}

return do, nil
}

func runSay(options *sayOptions) func(cmd *cli.Command, args []string) error {
Expand Down
Loading