Skip to content
This repository was archived by the owner on Jan 4, 2025. It is now read-only.

Commit 60477d6

Browse files
💀 Fix bug that gowl -h and gowl -V are not working if .gowlconfig is not existed
1 parent d9e3a04 commit 60477d6

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

args.go

+7-3
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,23 @@ type Args struct {
4141
}
4242

4343
// CreateArgs creates Args
44-
func CreateArgs(usage string, argv []string, version string) (Args, error) {
44+
func CreateArgs(usage string, argv []string, version string) (Args, bool, error) {
4545
parser := &docopt.Parser{
4646
HelpHandler: docopt.PrintHelpOnly,
4747
OptionsFirst: false,
4848
}
4949

5050
opts, err := parser.ParseArgs(usage, argv, version)
5151
if err != nil {
52-
return Args{}, errors.Wrap(err, "Fail to parse arguments.")
52+
return Args{}, false, errors.Wrap(err, "Fail to parse arguments.")
53+
}
54+
55+
if len(opts) == 0 {
56+
return Args{}, true, nil
5357
}
5458

5559
var args Args
5660
opts.Bind(&args)
5761

58-
return args, nil
62+
return args, false, nil
5963
}

main.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,13 @@ func getRoot(config Config) string {
2727
}
2828

2929
func main() {
30-
args, err := CreateArgs(usage, os.Args[1:], version)
30+
args, appEnd, err := CreateArgs(usage, os.Args[1:], version)
3131
if err != nil {
3232
log.Fatal(errors.Wrap(err, "Fail to create arguments."))
3333
}
34+
if appEnd {
35+
return
36+
}
3437

3538
config, err := CreateConfig()
3639
if err != nil {
@@ -62,5 +65,4 @@ func main() {
6265
log.Fatal(errors.Wrap(err, "Fail to command `list`"))
6366
}
6467
}
65-
6668
}

0 commit comments

Comments
 (0)