Skip to content

Commit af45b30

Browse files
committed
Fix up usage messages a bit.
1 parent 72c0c53 commit af45b30

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

git-subtrac.go

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package main
22

33
import (
44
"fmt"
5-
"github.com/pborman/getopt/v2"
5+
"github.com/pborman/getopt"
66
"gopkg.in/src-d/go-git.v4"
77
"log"
88
"os"
@@ -13,15 +13,19 @@ func fatalf(fmt string, args ...interface{}) {
1313
}
1414

1515
var usage_str = `
16-
Usage: %v [-d GIT_DIR] <command>
17-
1816
Commands:
19-
cid <ref> Generate a tracking commit id based on the given ref
17+
cid <ref> Print the id of a tracking commit based on the given ref
2018
update Update all local branches with a matching *.trac branch
2119
`
2220

21+
func usage() {
22+
fmt.Fprintf(os.Stderr, "\n")
23+
getopt.PrintUsage(os.Stderr)
24+
fmt.Fprintf(os.Stderr, usage_str)
25+
}
26+
2327
func usagef(format string, args ...interface{}) {
24-
fmt.Fprintf(os.Stderr, usage_str[1:], os.Args[0])
28+
usage()
2529
fmt.Fprintf(os.Stderr, "\nfatal: "+format+"\n", args...)
2630
os.Exit(99)
2731
}
@@ -30,8 +34,9 @@ func main() {
3034
log.SetFlags(0)
3135
infof := log.Printf
3236

33-
repodir := getopt.StringLong("git-dir", 'd', ".", "path to git repo")
34-
excludes := getopt.ListLong("exclude", 'x', "", "commitids to exclude")
37+
getopt.SetUsage(usage)
38+
repodir := getopt.StringLong("git-dir", 'd', ".", "path to git repo", "GIT_DIR")
39+
excludes := getopt.ListLong("exclude", 'x', "commitids to exclude", "commitids...")
3540
autoexclude := getopt.BoolLong("auto-exclude", 0, "auto exclude missing commits")
3641
verbose := getopt.BoolLong("verbose", 'v', "verbose mode")
3742
getopt.Parse()
@@ -52,6 +57,7 @@ func main() {
5257
} else {
5358
debugf = func(fmt string, args ...interface{}) {}
5459
}
60+
5561
c := NewCache(*repodir, r, *excludes, *autoexclude, debugf, infof)
5662

5763
switch args[0] {

0 commit comments

Comments
 (0)