-
Notifications
You must be signed in to change notification settings - Fork 3
/
git.go
51 lines (38 loc) · 1.01 KB
/
git.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package main
import (
"flag"
"fmt"
"github.com/hexops/cmder"
)
// gitCommands contains all registered 'wrench git' subcommands.
var gitCommands cmder.Commander
var gitFlagSet = flag.NewFlagSet("git", flag.ExitOnError)
func init() {
const usage = `wrench git: manage git repositories
Usage:
wrench git <command> [arguments]
The commands are:
clone clone all repositories
status status all repositories
commitpush commit and push all repositories
resethard git reset --hard all repositories
Use "wrench git <command> -h" for more information about a command.
`
usageFunc := func() {
fmt.Printf("%s", usage)
}
gitFlagSet.Usage = usageFunc
// Handles calls to our subcommand.
handler := func(args []string) error {
_ = gitFlagSet.Parse(args)
gitCommands.Run(gitFlagSet, "wrench git", usage, args)
return nil
}
// Register the command.
commands = append(commands, &cmder.Command{
FlagSet: gitFlagSet,
Aliases: []string{},
Handler: handler,
UsageFunc: usageFunc,
})
}