Skip to content

Commit 6829220

Browse files
committed
update example apps
1 parent 69979ac commit 6829220

File tree

9 files changed

+32
-46
lines changed

9 files changed

+32
-46
lines changed

def_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1620,7 +1620,7 @@ func rootCmdForTesting() (root *cmdr.RootCommand) {
16201620
// Version: consul_tags.Version,
16211621
// VersionInt: consul_tags.VersionInt,
16221622
Copyright: "consul-tags is an effective devops tool",
1623-
Author: "Hedzr Yeh <hedzrz@gmail.com>",
1623+
Author: "Hedzr Yeh <hedzr@duck.com>",
16241624
}
16251625

16261626
cmdr.BuildXref(root)

examples/demo/demo/entry.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ import (
1111

1212
// Entry is app main entry
1313
func Entry() {
14-
// logrus.SetLevel(logrus.DebugLevel)
15-
// logrus.SetFormatter(&logrus.TextFormatter{ForceColors: true})
16-
1714
if err := cmdr.Exec(rootCmd,
1815
// To disable internal commands and flags, uncomment the following codes
1916
// cmdr.WithBuiltinCommands(false, false, false, false, false),

examples/demo/demo/root_cmd.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ $ {{.AppName}} gen man
2323
$ {{.AppName}} --help
2424
show help screen.
2525
`
26-
overview = ``
26+
// overview = ``
2727
)
2828

2929
var (
@@ -102,7 +102,7 @@ var (
102102
Version: cmdr.Version,
103103
VersionInt: cmdr.VersionInt,
104104
Copyright: copyright,
105-
Author: "Hedzr Yeh <hedzrz@gmail.com>",
105+
Author: "Hedzr Yeh <hedzr@duck.com>",
106106
}
107107

108108
msCommands = &cmdr.Command{

examples/example-app/main.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@ import (
1414
)
1515

1616
func main() {
17-
Entry()
17+
Run()
1818
}
1919

20-
func Entry() {
21-
root := buildRootCmd()
22-
if err := cmdr.Exec(root, options...); err != nil {
23-
log.Fatalf("error occurs in app running: %+v\n", err)
24-
}
20+
func Run() {
21+
log.Fatal(cmdr.Exec(buildRootCmd(), options...)) // since hedzr/log 1.6.1, log.Fatal/Panic can ignore nil safely
22+
// root := buildRootCmd()
23+
// if err := cmdr.Exec(root, options...); err != nil {
24+
// log.Fatalf("error occurs in app running: %+v\n", err)
25+
// }
2526
}
2627

2728
func buildRootCmd() (rootCmd *cmdr.RootCommand) {

examples/fluent/cmdr/entry.go

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,19 @@ package cmdr
22

33
import (
44
"fmt"
5-
"github.com/hedzr/log"
65
"net"
76
"time"
87

8+
"github.com/hedzr/log"
9+
910
"github.com/hedzr/cmdr"
1011
"github.com/hedzr/cmdr/examples/internal"
1112
"github.com/hedzr/cmdr/plugin/colortable"
1213
"github.com/hedzr/cmdr/plugin/pprof"
1314
)
1415

15-
// Entry is real main entry for this app
16-
func Entry() {
16+
// Run is real main entry for this app
17+
func Run() {
1718
// logrus.SetLevel(logrus.DebugLevel)
1819
// logrus.SetFormatter(&logrus.TextFormatter{ForceColors: true})
1920

@@ -24,8 +25,7 @@ func Entry() {
2425
// }
2526
// }()
2627

27-
if err := cmdr.Exec(buildRootCmd(),
28-
28+
log.Fatal(cmdr.Exec(buildRootCmd(),
2929
// To disable internal commands and flags, uncomment the following codes
3030
// cmdr.WithBuiltinCommands(false, false, false, false, false),
3131

@@ -55,9 +55,7 @@ func Entry() {
5555
colortable.WithColorTableCommand(),
5656
optAddTraceOption,
5757
optAddServerExtOption,
58-
); err != nil {
59-
cmdr.Logger.Fatalf("error: %v", err)
60-
}
58+
)) // since hedzr/log 1.6.1, log.Fatal/Panic can ignore nil safely
6159
}
6260

6361
func buildRootCmd() (rootCmd *cmdr.RootCommand) {
@@ -170,7 +168,7 @@ func kvCommand(root cmdr.OptCmd) {
170168
AttachTo(kvRestoreCmd)
171169
}
172170

173-
func msCommand(root cmdr.OptCmd) {
171+
func msCommand(root cmdr.OptCmd) { //nolint:funlen //a test
174172
// ms
175173

176174
msCmd := cmdr.NewSubCmd().Titles("micro-service", "ms", "microservice").
@@ -393,19 +391,19 @@ func msCommand(root cmdr.OptCmd) {
393391
}
394392

395393
const (
396-
appName = "fluent"
397-
copyright = "fluent is an effective devops tool"
398-
desc = "fluent is an effective devops tool. It make an demo application for `cmdr`."
399-
longDesc = "fluent is an effective devops tool. It make an demo application for `cmdr`."
400-
examples = `
394+
appName = "fluent"
395+
// copyright = "fluent is an effective devops tool"
396+
desc = "fluent is an effective devops tool. It make an demo application for `cmdr`."
397+
longDesc = "fluent is an effective devops tool. It make an demo application for `cmdr`."
398+
examples = `
401399
$ {{.AppName}} gen shell [--bash|--zsh|--auto]
402400
generate bash/shell completion scripts
403401
$ {{.AppName}} gen man
404402
generate linux man page 1
405403
$ {{.AppName}} --help
406404
show help screen.
407405
`
408-
overview = ``
406+
// overview = ``
409407

410408
zero = 0
411409
)

examples/fluent/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ func main() {
1919
// }
2020
// }()
2121

22-
mycmdr.Entry()
22+
mycmdr.Run()
2323
}

examples/short/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ var (
4444
Version: cmdr.Version,
4545
VersionInt: cmdr.VersionInt,
4646
Copyright: "austr is an effective devops tool",
47-
Author: "Hedzr Yeh <hedzrz@gmail.com>",
47+
Author: "Hedzr Yeh <hedzr@duck.com>",
4848
}
4949

5050
serverCommands = &cmdr.Command{

examples/short/main.go

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,20 @@
55
package main
66

77
import (
8-
"fmt"
8+
"log"
99

1010
"github.com/hedzr/cmdr"
1111
"github.com/hedzr/cmdr/plugin/pprof"
1212
)
1313

1414
func main() {
15-
// logrus.SetLevel(logrus.DebugLevel)
16-
// logrus.SetFormatter(&logrus.TextFormatter{ForceColors: true,})
17-
18-
if err := cmdr.Exec(rootCmd,
15+
log.Fatal(cmdr.Exec(rootCmd,
1916
// To disable internal commands and flags, uncomment the following codes
2017
cmdr.WithBuiltinCommands(true, false, true, true, true),
2118
// daemon.WithDaemon(svr.NewDaemon(), nil, nil, nil),
2219
pprof.GetCmdrProfilingOptions("cpu"),
2320
// cmdr.WithHelpTabStop(40),
24-
); err != nil {
25-
fmt.Printf("Error: %v", err)
26-
}
21+
)) // since hedzr/log 1.6.1, log.Fatal/Panic can ignore nil safely
2722
}
2823

2924
var (
@@ -43,7 +38,7 @@ var (
4338
Version: cmdr.Version,
4439
VersionInt: cmdr.VersionInt,
4540
Copyright: "austr is an effective devops tool",
46-
Author: "Hedzr Yeh <hedzrz@gmail.com>",
41+
Author: "Hedzr Yeh <hedzr@duck.com>",
4742
}
4843

4944
serverCommands = &cmdr.Command{

examples/wget-demo/main.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,14 @@ import (
1010
)
1111

1212
func main() {
13-
// logrus.SetLevel(logrus.DebugLevel)
14-
// logrus.SetFormatter(&logrus.TextFormatter{ForceColors: true})
15-
16-
if err := cmdr.Exec(rootCmd,
13+
log.Fatal(cmdr.Exec(rootCmd,
1714
// To disable internal commands and flags, uncomment the following codes
1815
cmdr.WithBuiltinCommands(false, false, false, false, true),
1916
// daemon.WithDaemon(svr.NewDaemon(), nil, nil, nil),
2017
cmdr.WithLogx(log.GetLogger()),
2118
// cmdr.WithHelpTabStop(40),
2219
// cmdr.WithNoColor(true),
23-
); err != nil {
24-
log.Fatalf("Error: %v", err)
25-
}
20+
)) // since hedzr/log 1.6.1, log.Fatal/Panic can ignore nil safely
2621
}
2722

2823
const (
@@ -64,7 +59,7 @@ var (
6459
Usage: wget [OPTION]... [URL]...
6560
6661
Mandatory arguments to long options are mandatory for short options too.`,
67-
Author: "Hedzr Yeh <hedzrz@gmail.com>",
62+
Author: "Hedzr Yeh <hedzr@duck.com>",
6863
}
6964

7065
startupFlags = []*cmdr.Flag{

0 commit comments

Comments
 (0)