-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
45 lines (36 loc) · 805 Bytes
/
main.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
package main
import (
"flag"
"os"
"gitlab.com/nlulic/lit/logger"
)
func main() {
commitCmd := flag.NewFlagSet("commit", flag.ExitOnError)
commitMsg := commitCmd.String("m", "", "commit message")
branchCmd := flag.NewFlagSet("branch", flag.ExitOnError)
checkoutCmd := flag.NewFlagSet("checkout", flag.ExitOnError)
lit := NewLit(
logger.New(logger.LevelInfo),
)
if len(os.Args) < 2 {
lit.logger.Fatal("fatal: subcommand expected")
os.Exit(1)
}
switch os.Args[1] {
case "init":
lit.Init()
case "commit":
commitCmd.Parse(os.Args[2:])
lit.Commit(*commitMsg)
case "branch":
branchCmd.Parse(os.Args[2:])
lit.Branch(branchCmd.Arg(0))
case "checkout":
checkoutCmd.Parse(os.Args[2:])
lit.Checkout(checkoutCmd.Arg(0))
case "log":
lit.Log()
default:
os.Exit(1)
}
}