99)
1010
1111func BuildCLI () (* cli.Command , error ) {
12- demo , err := cli .New (
12+ return cli .New (
1313 "demo" ,
1414 cli .Short ("An example CLI to demonstrate the library and play with it for real." ),
1515 cli .Version ("dev" ),
@@ -20,11 +20,6 @@ func BuildCLI() (*cli.Command, error) {
2020 cli .Allow (cli .NoArgs ()),
2121 cli .SubCommands (buildSayCommand , buildDoCommand ),
2222 )
23- if err != nil {
24- return nil , err
25- }
26-
27- return demo , nil
2823}
2924
3025type sayOptions struct {
@@ -35,7 +30,7 @@ type sayOptions struct {
3530
3631func buildSayCommand () (* cli.Command , error ) {
3732 var options sayOptions
38- say , err := cli .New (
33+ return cli .New (
3934 "say" ,
4035 cli .Short ("Print a message" ),
4136 cli .Example ("Say a well known phrase" , "demo say hello world" ),
@@ -45,11 +40,6 @@ func buildSayCommand() (*cli.Command, error) {
4540 cli .Flag (& options .count , "count" , 'c' , 0 , "Count the things" ),
4641 cli .Flag (& options .thing , "thing" , 't' , "" , "Name of the thing" ),
4742 )
48- if err != nil {
49- return nil , err
50- }
51-
52- return say , nil
5343}
5444
5545type doOptions struct {
@@ -61,7 +51,7 @@ type doOptions struct {
6151
6252func buildDoCommand () (* cli.Command , error ) {
6353 var options doOptions
64- do , err := cli .New (
54+ return cli .New (
6555 "do" ,
6656 cli .Short ("Do a thing" ),
6757 cli .Example ("Do something" , "demo do something --fast" ),
@@ -74,11 +64,6 @@ func buildDoCommand() (*cli.Command, error) {
7464 cli .Flag (& options .duration , "duration" , 'd' , 1 * time .Second , "Do the thing for a specific duration" ),
7565 cli .Run (runDo (& options )),
7666 )
77- if err != nil {
78- return nil , err
79- }
80-
81- return do , nil
8267}
8368
8469func runSay (options * sayOptions ) func (cmd * cli.Command , args []string ) error {
0 commit comments