@@ -2,7 +2,7 @@ package main
2
2
3
3
import (
4
4
"fmt"
5
- "github.com/pborman/getopt/v2 "
5
+ "github.com/pborman/getopt"
6
6
"gopkg.in/src-d/go-git.v4"
7
7
"log"
8
8
"os"
@@ -13,15 +13,19 @@ func fatalf(fmt string, args ...interface{}) {
13
13
}
14
14
15
15
var usage_str = `
16
- Usage: %v [-d GIT_DIR] <command>
17
-
18
16
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
20
18
update Update all local branches with a matching *.trac branch
21
19
`
22
20
21
+ func usage () {
22
+ fmt .Fprintf (os .Stderr , "\n " )
23
+ getopt .PrintUsage (os .Stderr )
24
+ fmt .Fprintf (os .Stderr , usage_str )
25
+ }
26
+
23
27
func usagef (format string , args ... interface {}) {
24
- fmt . Fprintf ( os . Stderr , usage_str [ 1 :], os . Args [ 0 ] )
28
+ usage ( )
25
29
fmt .Fprintf (os .Stderr , "\n fatal: " + format + "\n " , args ... )
26
30
os .Exit (99 )
27
31
}
@@ -30,8 +34,9 @@ func main() {
30
34
log .SetFlags (0 )
31
35
infof := log .Printf
32
36
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..." )
35
40
autoexclude := getopt .BoolLong ("auto-exclude" , 0 , "auto exclude missing commits" )
36
41
verbose := getopt .BoolLong ("verbose" , 'v' , "verbose mode" )
37
42
getopt .Parse ()
@@ -52,6 +57,7 @@ func main() {
52
57
} else {
53
58
debugf = func (fmt string , args ... interface {}) {}
54
59
}
60
+
55
61
c := NewCache (* repodir , r , * excludes , * autoexclude , debugf , infof )
56
62
57
63
switch args [0 ] {
0 commit comments