-
-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy path_dep
336 lines (322 loc) · 13.1 KB
/
_dep
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
#compdef dep
# -----------------------------------------------------------------------------
# Copyright (c) 2017 The Go Authors. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# -----------------------------------------------------------------------------
#
# github.com/golang/dep
#
# Dep is a tool for managing dependencies for Go projects
#
# Usage: "dep [command]"
#
# Commands:
#
# init Initialize a new project with manifest and lock files
# status Report the status of the project's dependencies
# ensure Ensure a dependency is safely vendored in the project
# prune Prune the vendor tree of unused packages
# version Show the dep version information
#
# Examples:
# dep init set up a new project
# dep ensure install the project's dependencies
# dep ensure -update update the locked versions of all dependencies
# dep ensure -add github.com/pkg/errors add a dependency to the project
#
# Use "dep help [command]" for more information about a command.
#
# -----------------------------------------------------------------------------
#
# Usage: dep init [root]
#
# Initialize the project at filepath root by parsing its dependencies, writing
# manifest and lock files, and vendoring the dependencies. If root isn't
# specified, use the current directory.
#
# When configuration for another dependency management tool is detected, it is
# imported into the initial manifest and lock. Use the -skip-tools flag to
# disable this behavior. The following external tools are supported:
# glide, godep, vndr, govend, gb, gvt, govendor, glock.
#
# Any dependencies that are not constrained by external configuration use the
# GOPATH analysis below.
#
# By default, the dependencies are resolved over the network. A version will be
# selected from the versions available from the upstream source per the following
# algorithm:
#
# - Tags conforming to semver (sorted by semver rules)
# - Default branch(es) (sorted lexicographically)
# - Non-semver tags (sorted lexicographically)
#
# An alternate mode can be activated by passing -gopath. In this mode, the version
# of each dependency will reflect the current state of the GOPATH. If a dependency
# doesn't exist in the GOPATH, a version will be selected based on the above
# network version selection algorithm.
#
# A Gopkg.toml file will be written with inferred version constraints for all
# direct dependencies. Gopkg.lock will be written with precise versions, and
# vendor/ will be populated with the precise versions written to Gopkg.lock.
#
# Flags:
#
# -gopath search in GOPATH for dependencies (default: false)
# -no-examples don't include example in Gopkg.toml (default: false)
# -skip-tools skip importing configuration from other dependency managers (default: false)
# -v enable verbose logging (default: false)
#
# -----------------------------------------------------------------------------
#
# Usage: dep status [package...]
#
# With no arguments, print the status of each dependency of the project.
#
# PROJECT Import path
# CONSTRAINT Version constraint, from the manifest
# VERSION Version chosen, from the lock
# REVISION VCS revision of the chosen version
# LATEST Latest VCS revision available
# PKGS USED Number of packages from this project that are actually used
#
# You may use the -f flag to create a custom format for the output of the
# dep status command. The available fields you can utilize are as follows:
# ProjectRoot, Constraint, Version, Revision, Latest, and PackageCount.
#
# Status returns exit code zero if all dependencies are in a "good state".
#
# Flags:
#
# -dot output the dependency graph in GraphViz format (default: false)
# -examples print detailed usage examples (default: false)
# -f output in text/template format (default: <none>)
# -json output in JSON format (default: false)
# -missing only show missing dependencies (default: false)
# -old only show out-of-date dependencies (default: false)
# -v enable verbose logging (default: false)
#
# -----------------------------------------------------------------------------
#
# Usage: dep ensure [-update | -add] [-no-vendor | -vendor-only] [-dry-run] [-v] [<spec>...]
#
# Project spec:
#
# <import path>[:alt source URL][@<constraint>]
#
#
# Ensure gets a project into a complete, reproducible, and likely compilable state:
#
# * All non-stdlib imports are fulfilled
# * All rules in Gopkg.toml are respected
# * Gopkg.lock records precise versions for all dependencies
# * vendor/ is populated according to Gopkg.lock
#
# Ensure has fast techniques to determine that some of these steps may be
# unnecessary. If that determination is made, ensure may skip some steps. Flags
# may be passed to bypass these checks; -vendor-only will allow an out-of-date
# Gopkg.lock to populate vendor/, and -no-vendor will update Gopkg.lock (if
# needed), but never touch vendor/.
#
# The effect of passing project spec arguments varies slightly depending on the
# combination of flags that are passed.
#
#
# Examples:
#
# dep ensure Populate vendor from existing Gopkg.toml and Gopkg.lock
# dep ensure -add github.com/pkg/foo Introduce a named dependency at its newest version
# dep ensure -add github.com/pkg/foo@^1.0.1 Introduce a named dependency with a particular constraint
#
# For more detailed usage examples, see dep ensure -examples.
#
# Flags:
#
# -add add new dependencies, or populate Gopkg.toml with constraints for existing dependencies (default: false)
# -dry-run only report the changes that would be made (default: false)
# -examples print detailed usage examples (default: false)
# -no-vendor update Gopkg.lock (if needed), but do not update vendor/ (default: false)
# -update update the named dependencies (or all, if none are named) in Gopkg.lock to the latest allowed by Gopkg.toml (default: false)
# -v enable verbose logging (default: false)
# -vendor-only populate vendor/ from Gopkg.lock without updating it first (default: false)
#
# -----------------------------------------------------------------------------
#
# Usage: dep prune
#
# Prune was merged into the ensure command.
# Set prune options in the manifest and it will be applied after every ensure.
# dep prune will be removed in a future version of dep, causing this command to exit non-0.
#
# Flags:
#
# -v enable verbose logging (default: false)
#
# -----------------------------------------------------------------------------
#
# Usage: dep version
#
# Show the dep version information
#
# Flags:
#
# -v enable verbose logging (default: false)
#
# -----------------------------------------------------------------------------
#
# flag provided but not defined: -v
# Usage: dep check [-q] [-skip-lock] [-skip-vendor]
#
# Check determines if your project is in a good state. If problems are found, it
# prints a description of each issue, then exits 1. Passing -q suppresses output.
#
# Flags control which specific checks will be run. By default, dep check verifies
# that Gopkg.lock is in sync with Gopkg.toml and the imports in your project's .go
# files, and that the vendor directory is in sync with Gopkg.lock. These checks
# can be disabled with -skip-lock and -skip-vendor, respectively.
#
# (See https://golang.github.io/dep/docs/ensure-mechanics.html#staying-in-sync for
# more information on what it means to be "in sync.")
#
# If your workflow necessitates that you modify the contents of vendor, you can
# force check to ignore hash mismatches on a per-project basis by naming
# project roots in Gopkg.toml's "noverify" list.
#
# Flags:
#
# -q Suppress non-error output (default: false)
# -skip-lock Skip checking that imports and Gopkg.toml are in sync with Gopkg.lock (default: false)
# -skip-vendor Skip checking that vendor is in sync with Gopkg.lock (default: false)
#
# -----------------------------------------------------------------------------
function _dep() {
local context curcontext=$curcontext state line ret=1
declare -A opt_args
local -a commands
commands=(
'init:Initialize a new project with manifest and lock files'
"status:Report the status of the project's dependencies"
'ensure:Ensure a dependency is safely vendored in the project'
'prune:Prune the vendor tree of unused packages'
'version:Show the dep version information'
'check:Check if imports, Gopkg.toml, and Gopkg.lock are in sync'
)
_go_packages() {
local gopaths
declare -a gopaths
gopaths=("${(s/:/)$(go env GOPATH)}")
for p in $gopaths; do
_alternative ':go packages:_path_files -W "$p/src" -/'
done
}
# TODO(zchee): semver spec completion
# __dep_spec() {
# if compset -P '*@'; then
# local version_spec
# _version_spec=(
# '@^:major version. If github.com/pkg/foo@^1.0.1, matching \>= 1.0.1, < 2.0.0'
# '@~:minor version. If github.com/pkg/foo@~1.0.1, matching 1.0.x preferring latest'
# )
# _arguments \
# '*:version spec:_version_spec' && ret=0
# elif compset -P '*:'; then
# local gopaths
# declare -a gopaths
# gopaths=("${(s/:/)$(go env GOPATH)}")
# for p in $gopaths; do
# _alternative ':different dependency location:_path_files -W "$p/src" -/'
# done
# else
# _arguments \
# '*:gopath packages:_go_packages -qS@' \
# && ret=0
# fi
#
# return ret
# }
_arguments -C \
"1: :{_describe 'dep ubcommand' commands}" \
'*:: :->args' \
&& ret=0
case $words[1] in
init)
_arguments \
'-gopath[search in GOPATH for dependencies]' \
"-no-examples[don't include example in Gopkg.toml]" \
'-skip-tools[skip importing configuration from other dependency managers]' \
'-v[enable verbose logging]' \
'-help[show help]' \
'*:root:_directories' \
&& ret=1
;;
status)
_arguments \
'-detail[include more detail in the chosen format]' \
'-dot[output the dependency graph in GraphViz format]' \
'-examples[print detailed usage examples]' \
'-f[output in text/template format]:template format' \
'-json[output in JSON format]' \
'-lock[output in the lock file format \(assumes -detail\)]' \
'-missing[NOT IMPLEMENTED: only show missing dependencies]' \
'-old[only show out-of-date dependencies]' \
'-out[path to a file to which to write the output. Blank value will be ignored]:output file:_files' \
'-v[enable verbose logging]' \
'-help[show help]' \
'*: :_go_packages' \
&& ret=1
;;
ensure)
_arguments \
'-add[add new dependencies, or populate Gopkg.toml with constraints for existing dependencies]' \
'-dry-run[only report the changes that would be made]' \
'-examples[print detailed usage examples]' \
'-no-vendor[update Gopkg.lock \(if needed\), but do not update vendor/]' \
'-update[update the named dependencies \(or all, if none are named\) in Gopkg.lock to the latest allowed by Gopkg.toml]' \
'-v[enable verbose logging]' \
'-vendor-only[populate vendor/ from Gopkg.lock without updating it first]' \
'-help[show help]' \
&& ret=1
;;
(prune|version)
_arguments \
'-v[enable verbose logging]' \
'-help[show help]' \
&& ret=1
;;
check)
_arguments \
'-q[Suppress non-error output]' \
'-skip-lock[Skip checking that imports and Gopkg.toml are in sync with Gopkg.lock]' \
'-skip-vendor[Skip checking that vendor is in sync with Gopkg.lock]' \
'-help[show help]' \
&& ret=1
;;
esac
return ret
}
_dep "$*"
# vim:ft=zsh:et:sts=2:sw=2