Compare commits

...
3 Commits
Author SHA1 Message Date
Zachary Rice 923dcf0311 Merge pull request #117 from camaya/update-help-option
Update help option
2018-10-17 08:42:20 -04:00
Cristhian Amaya 8896cf66cd Update help option
* Show program usage when no arguments are provided
* Exit program after the -h or --help options are used
2018-10-15 17:10:44 +02:00
zach rice df133ccaf8 version boss strikes AGAIN 2018-10-12 19:01:42 -05:00
2 changed files with 19 additions and 3 deletions

No files matched your search

+4 -1
View File
@@ -1,6 +1,9 @@
CHANGELOG
=========
1.12.1
----
- Show program usage when no arguments are provided
- Exit program after the -h or --help options are used
1.12.0
----
- removing --csv option
+15 -2
View File
@@ -126,7 +126,7 @@ type gitDiff struct {
}
const defaultGithubURL = "https://api.github.com/"
const version = "1.11.1"
const version = "1.12.1"
const errExit = 2
const leakExit = 1
const defaultConfig = `
@@ -207,7 +207,20 @@ func init() {
}
func main() {
_, err := flags.Parse(&opts)
parser := flags.NewParser(&opts, flags.Default)
_, err := parser.Parse()
if err != nil {
if flagsErr, ok := err.(*flags.Error); ok && flagsErr.Type == flags.ErrHelp {
os.Exit(0)
}
}
if len(os.Args) == 1 {
parser.WriteHelp(os.Stdout)
os.Exit(0)
}
if opts.Version {
fmt.Println(version)
os.Exit(0)