Skip to content

Commit

Permalink
Merge pull request #6 from tadashi-aikawa/0.5.2
Browse files Browse the repository at this point in the history
0.5.2
  • Loading branch information
tadashi-aikawa committed Nov 28, 2018
2 parents d9e3a04 + b61bebc commit 8bbffd6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,6 @@ You have to create PR and merge.
After you merged PR, then

```
$ make release version=x.y.z
$ make deploy version=x.y.z
```

12 changes: 8 additions & 4 deletions args.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"github.com/pkg/errors"
)

const version = "0.5.1"
const version = "0.5.2"
const usage = `Gowl.
Usage:
Expand Down Expand Up @@ -41,19 +41,23 @@ type Args struct {
}

// CreateArgs creates Args
func CreateArgs(usage string, argv []string, version string) (Args, error) {
func CreateArgs(usage string, argv []string, version string) (Args, bool, error) {
parser := &docopt.Parser{
HelpHandler: docopt.PrintHelpOnly,
OptionsFirst: false,
}

opts, err := parser.ParseArgs(usage, argv, version)
if err != nil {
return Args{}, errors.Wrap(err, "Fail to parse arguments.")
return Args{}, false, errors.Wrap(err, "Fail to parse arguments.")
}

if len(opts) == 0 {
return Args{}, true, nil
}

var args Args
opts.Bind(&args)

return args, nil
return args, false, nil
}
6 changes: 4 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,13 @@ func getRoot(config Config) string {
}

func main() {
args, err := CreateArgs(usage, os.Args[1:], version)
args, appEnd, err := CreateArgs(usage, os.Args[1:], version)
if err != nil {
log.Fatal(errors.Wrap(err, "Fail to create arguments."))
}
if appEnd {
return
}

config, err := CreateConfig()
if err != nil {
Expand Down Expand Up @@ -62,5 +65,4 @@ func main() {
log.Fatal(errors.Wrap(err, "Fail to command `list`"))
}
}

}

0 comments on commit 8bbffd6

Please sign in to comment.