-
Notifications
You must be signed in to change notification settings - Fork 34
/
main.go
138 lines (116 loc) · 3.46 KB
/
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
package main
import (
"crypto/tls"
"net/http"
"os"
"github.com/kovetskiy/godocs"
"github.com/kovetskiy/lorg"
"github.com/reconquest/hierr-go"
)
const (
version = `manul 1.6`
usage = version + `
manul is the tool for vendoring dependencies using git submodule technology.
Usage:
manul [options] -I [<dependency>...]
manul [options] -U [<dependency>...]
manul [options] -R [<dependency>...]
manul [options] -Q [-o]
manul [options] -C
manul [options] -T
manul -h
manul --version
Options:
-I --install Detect all dependencies and add git submodule into vendor directory.
If you don't specify any dependency, manul will
install all detected dependencies.
You can specify commit-ish that will be used as target to
instal: -I golang.org/x/net=34a235h1
-U --update Update specified already-vendored dependencies.
If you don't specify any vendored dependency, manul will
update all already-vendored dependencies.
You can specify commit-ish that will be used as target to
update: -U golang.org/x/net=34a235h1
-R --remove Stop vendoring of specified dependencies.
If you don't specify any dependency, manul will
remove all vendored dependencies.
-Q --query List all dependencies.
-o List only already-vendored dependencies.
-C --clean Detect all unused vendored dependencies and remove it.
-T --tree Show dependencies tree.
-i --import Show used import path instead of git repo.
-t --testing Include dependencies from tests.
-r --recursive Be recursive.
-h --help Show help message.
-v --verbose Be verbose.
--trace Be very verbose.
--version Show version.
`
)
var (
verbose bool
tracing bool
testing bool
workdir string
logger = lorg.NewLog()
)
func init() {
var err error
newArgs := make([]string, 0, len(os.Args))
for _, arg := range os.Args {
if arg == "--integration-test" {
testing = true
} else if arg == "--insecure-skip-verify" {
http.DefaultClient.Transport = &http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true,
},
}
} else {
newArgs = append(newArgs, arg)
}
}
os.Args = newArgs
workdir, err = os.Getwd()
if err != nil {
hierr.Fatalf(
err,
"unable to get current working directory",
)
}
logger.SetIndentLines(true)
}
func main() {
args := godocs.MustParse(usage, version)
var (
dependencies, _ = args["<dependency>"].([]string)
recursive = args["--recursive"].(bool)
withTests = args["--testing"].(bool)
)
if args["--verbose"].(bool) {
verbose = true
logger.SetLevel(lorg.LevelDebug)
}
if args["--trace"].(bool) {
logger.SetLevel(lorg.LevelTrace)
}
var err error
switch {
case args["--tree"].(bool):
err = handleTree(withTests, args["--import"].(bool))
case args["--install"].(bool):
err = handleInstall(recursive, withTests, dependencies)
case args["--update"].(bool):
err = handleUpdate(recursive, withTests, dependencies)
case args["--query"].(bool):
onlyVendored := args["-o"].(bool)
err = handleQuery(recursive, withTests, onlyVendored)
case args["--remove"].(bool):
err = handleRemove(dependencies)
case args["--clean"].(bool):
err = handleClean(recursive, withTests)
}
if err != nil {
logger.Fatal(err)
}
}