Skip to content

Commit

Permalink
cli: simplify example code
Browse files Browse the repository at this point in the history
  • Loading branch information
SamWhited committed Nov 10, 2018
1 parent 8c8ba2c commit 5252292
Showing 1 changed file with 15 additions and 19 deletions.
34 changes: 15 additions & 19 deletions example_subcommands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,26 @@ func Example_subcommands() {
fmt.Println("Ran go")
return nil
},
Commands: []*cli.Command{
&cli.Command{
Usage: `mod <command> [arguments]`,
Description: `Go mod provides access to operations on modules.
Commands: []*cli.Command{{
Usage: `mod <command> [arguments]`,
Description: `Go mod provides access to operations on modules.
Note that support for modules is built into all the go commands…`,
Run: func(c *cli.Command, args ...string) error {
fmt.Println("Ran go mod")
return nil
},
Commands: []*cli.Command{
&cli.Command{
Usage: `tidy [-v]`,
Description: `Add missing and remove unused modules.
Run: func(c *cli.Command, args ...string) error {
fmt.Println("Ran go mod")
return nil
},
Commands: []*cli.Command{{
Usage: `tidy [-v]`,
Description: `Add missing and remove unused modules.
Tidy makes sure go.mod matches the source code in the module…`,
Run: func(c *cli.Command, args ...string) error {
fmt.Println("Ran go mod tidy")
return nil
},
},
Run: func(c *cli.Command, args ...string) error {
fmt.Println("Ran go mod tidy")
return nil
},
},
},
}},
}},
}
cmds.Commands = append(cmds.Commands, cli.Help(cmds))
fmt.Println("$ go help")
Expand Down

0 comments on commit 5252292

Please sign in to comment.