Skip to content

Commit 4f6bfb5

Browse files
committed
Use a hand-written usage message
1 parent 9183d98 commit 4f6bfb5

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

git-sizer.go

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,26 @@ import (
1616
"github.com/spf13/pflag"
1717
)
1818

19+
const Usage = `usage: git-sizer [OPTS]
20+
--branches process all branches
21+
--tags process all tags
22+
--remotes process all remotes
23+
-v, --verbose report all statistics, whether concerning or not
24+
--threshold threshold minimum level of concern (i.e., number of stars)
25+
that should be reported. Default:
26+
'--threshold=1'.
27+
--critical only report critical statistics
28+
--names=[none|hash|full] display names of large objects in the specified
29+
style: 'none' (omit footnotes entirely), 'hash'
30+
(show only the SHA-1s of objects), or 'full'
31+
(show full names). Default is '--names=full'.
32+
-j, --json output results in JSON format
33+
--json-version=[1|2] choose which JSON format version to output.
34+
Default: --json-version=1.
35+
--[no-]progress report (don't report) progress to stderr.
36+
--version only report the git-sizer version number
37+
`
38+
1939
var ReleaseVersion string
2040
var BuildVersion string
2141

@@ -65,7 +85,10 @@ func mainImplementation() error {
6585
var progress bool
6686
var version bool
6787

68-
flags := pflag.NewFlagSet("", pflag.ContinueOnError)
88+
flags := pflag.NewFlagSet("git-sizer", pflag.ContinueOnError)
89+
flags.Usage = func() {
90+
fmt.Print(Usage)
91+
}
6992

7093
flags.BoolVar(&processBranches, "branches", false, "process all branches")
7194
flags.BoolVar(&processTags, "tags", false, "process all tags")
@@ -116,6 +139,9 @@ func mainImplementation() error {
116139

117140
err = flags.Parse(os.Args[1:])
118141
if err != nil {
142+
if err == pflag.ErrHelp {
143+
return nil
144+
}
119145
return err
120146
}
121147

0 commit comments

Comments
 (0)