-
Notifications
You must be signed in to change notification settings - Fork 8
/
_git-annex
198 lines (183 loc) · 6.61 KB
/
_git-annex
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
#compdef git-annex
#description:managing files while ignoring their content
# ZSH Completion for git-annex (http://git-annex.branchable.com/)
#
# This completion was written for git-annex version: 3.20111122~bpo60+2
#
# Note that this completion is still very much early alpha work in progress.
#
# This completion depends on Python for a jason parser, sorry. Unfortunately
# there is no such thing in zsh (yet).
#
# Skeleton implementation by Frank Terbeck <[email protected]>
# Blanks filled in by Valentin Haenel <[email protected]>
# Licence: WTFPL (http://sam.zoy.org/wtfpl/)
#
# To use this completion drop it somewhere in you $fpath, e.g.:
#
# $ git clone $CLONEURL
# $ fpath+=$PWD/git-annex-zsh-completion
# $ compinit git-annex
#
# TODO
# ----
#
# * 'git annex add' to only complete files not in annex
#
local state line context
local -A opt_args
__annex_backend(){
local -a backends
backends=($(git annex status --fast --json |
python -c "
import sys
import json
parsed = json.loads(sys.stdin.read())
print ' '.join(parsed['supported backends'])"))
_describe -t backends backend backends
}
__annex_remotes(){
local -a remotes
remotes=($(git remote))
_describe -t remotes 'configured remote' remotes
}
__annex_repository(){
local -a currents
currents=('here')
_describe -t currents current currents
__annex_remotes
local -a descriptions
descriptions=($(git annex status --fast --json |
python -c "
import sys
import json
parsed = json.loads(sys.stdin.read())
descriptions = []
for repo in (parsed['trusted repositories']
+ parsed['semitrusted repositories']
+ parsed['untrusted repositories']):
descriptions.append(repo['description'])
print ' '.join(descriptions)"))
_describe -t descriptions description descriptions
local -a uuids
uuids=($(git annex status --fast --json |
python -c "
import sys
import json
parsed = json.loads(sys.stdin.read())
uuids = []
for repo in (parsed['trusted repositories']
+ parsed['semitrusted repositories']
+ parsed['untrusted repositories']):
uuids.append(repo['uuid'])
print ' '.join(uuids)"))
_describe -t uuids uuid uuids
}
local -a arguments
arguments=(
'--and[both previous and next option match]'
'(-a --auto)'{-a,--auto}'[automatic mode]'
'(-d --debug)'{-d,--debug}'[show debug messages]'
'(-x --exclude=)'{-x,--exclude=}'[skips files matching the globbing pattern]'
'(-b --backend=)'{-b,--backend=}'[specifies which key-value backend to use]::backend:__annex_backend'
'-c name=-[override git configuration settings]'
'(-C --copies=)'{-C,--copies=}'[skip files with fewer copies]'
'--force[force unsafe actions]'
'(-f --from=)'{-f,--from=}'[copy/move from repository]:repository:__annex_remotes'
'(-F --fast)'{-F,--fast}'[less expensive version of some commands]'
'(-i --in=)'{-i,--in=}'[skip files not present in a remote]:repository:__annex_repository'
'(-j --json)'{-j,--json}'[generate machine readable JSON]'
'(-k --key=)'{-k,--key=}'[specifies a key to operate on]'
'(-N --numcopies=)'{-N,--numcopies=}'[overrides annex.numcopies]'
'--not[negate next option]'
'--or[either previous or next option match]'
'--print0[output filenames terminated with nulls, for use with xargs -0]'
'(-t --to=)'{-t,--to=}'[copy/move to repository]:repository:__annex_remotes'
'--semitrust=-[override trust settings]:repository:__annex_repository'
'--trust=-[override trust settings]:repository:__annex_repository'
'--untrust=-[override trust settings]:repository:__annex_repository'
'--verbose[verbose display]'
'--quiet'
'-([open group of options]'
'-)[close group of options]'
': :->command'
'*:: :->subcmd'
)
_arguments -C $arguments
case $state in
(command)
local -a common
local -a setup
local -a maintenance
local -a query
local -a utility
local -a plumbing
common=(
add:'adds files in the path to the annex'
get:'makes the content of annexed files available in this repository'
drop:'drops the content of annexed files from this repository'
move:'move files from/to repositories'
copy:'copy from/to repositories'
unlock:'unlock a file for editing'
edit:'alias for the unlock command'
lock:'lock file again after editing'
sync:'synchronise with one or more remotes'
addurl:'downloads each url to a file, which is added to the annex.'
)
setup=(
init:'initialize an annex'
describe:'changes the description of a repository'
initremote:'set up a special remote'
trust:'records that a repository is trusted to not unexpectedly lose content'
untrust:'records that a repository is not trusted and could lose content at any time'
semitrust:'returns a repository to the default semi trusted state'
)
maintenance=(
fsck:'check annex consistency'
unused:'check for data that has no symlinks pointing to it'
dropunused:'drop unused data, as reported by unused'
merge:'merge the git-annex branches of remotes'
fix:'fix up symlinks that have become broken'
upgrade:'upgrades the repository to current layout'
)
query=(
version:'print version and repository information'
find:'search for present/missing files in current annex'
whereis:'show all repositories that contain a file'
status:'displays some statistics and other information'
map:'generate a visual map of repositories'
)
utility=(
migrate:'migrate annexd files to new backend'
unannex:'undo an accidental git annex add command'
uninit:'stop using git-annex entirely'
)
plumbing=(
pre-commit:'fixes up symlinks that are staged as part of a commit'
reinject:'moves a src file into the annex as the content of the dest file.'
dropkey:'drop annexd data for specified keys'
fromkey:'set file to link to given key'
)
_describe -t common_commands "common commands" common
_describe -t setup_commands "setup commands" setup
_describe -t maintenance_commands "maintenance commands" maintenance
_describe -t query_commands "query commands" query
_describe -t utility_commands "utility commands" utility
_describe -t plumbing_commands "plumbing commands" plumbing
;;
(subcmd)
case ${line[1]} in
(map|status)
_message 'No more arguments'
;;
(sync)
__annex_remotes
return true
;;
(*)
_arguments -C $arguments
_path_files
;;
esac
;;
esac