monotone

monotone Mtn Source Tree

Root/contrib/monotone.zsh_completion

1#compdef mtn # -*-sh-*-
2#
3# ZSH Completion for Monotone
4#
5# Author: Joel Reed <joelwreed@comcast.com>
6# Last changed by: Thomas Moschny <thomas.moschny@gmx.de>
7#
8#
9# Installing into /usr/share/zsh/site-functions:
10#
11# (1) If that directory is not already present in $fpath, add the line
12# "fpath=(/usr/share/zsh/site-functions $fpath)" to either your
13# system wide zshrc, or user ~/.zshrc.
14#
15# (2) Copy $MONOTONE/contrib/monotone.zsh_completion (this file) to
16# /usr/share/zsh/site-functions/_mtn
17#
18# Alternatively, you can install this file as _mtn into some directory
19# in your home (e.g. ~/.zsh), and add that directory to the $fpath.
20#
21
22# redefine _mtn.
23
24_mtn() {
25 local extra
26
27 _arguments -s : \
28 '--debug[print debug log to stderr while running]'\
29 '--dump=[file to dump debugging log to, on failure]:file:_files'\
30 '--log=[file to write the log to]:file:_files'\
31 '--quiet[suppress log and progress messages]'\
32 '--reallyquiet[suppress warning, verbose, informational and progress messages]'\
33 {'-h','--help'}'[display help message]'\
34 '(- *)--version[print version number, then exit]'\
35 '(- *)--full-version[print detailed version number, then exit]'\
36 {'-@+','--xargs='}'[insert command line arguments taken from the given file]:file:_files'\
37 '--ticker=[set ticker style]:style:(count dot none)'\
38 '--nostd[do not load standard lua hooks]'\
39 '--norc[do not load ~/.monotone/monotonerc or _MTN/monotonerc lua files]'\
40 '--rcfile=[load extra rc file]:file:_files'\
41 {'(--key)-k+','(-k)--key='}'[set key for signatures]:keys keys:_mtn_keys'\
42 {'(--db)-d+','(-d)--db='}'[set name of database]:file:_files'\
43 '--root=[limit search for working copy to specified root]:dir:_files -/'\
44 '--verbose[verbose completion output]'\
45 '--keydir=[set location of key store]:dir:_files -/'\
46 '--confdir=[set location of configuration directory]:dir:_files -/'\
47 '*::monotone command:_mtn_command'
48}
49
50# define monotone command dispatch function.
51
52(( $+functions[_mtn_command] )) ||
53_mtn_command() {
54 (( $+_mtn_cmds )) ||
55 _mtn_cmds=(
56add annotate approve asciik attr automate cat cert checkout ci
57clone co comment commit complete cvs_import db diff disapprove
58drop dropkey explicit_merge fdiff fload fmerge genkey
59get_roster heads help identify import list log ls merge
60merge_into_dir merge_into_workspace migrate_workspace mkdir mv
61passphrase pivot_root pluck privkey propagate pubkey pull push
62rcs_import read refresh_inodeprints rename revert rm serve set
63setup show_conflicts ssh_agent_add ssh_agent_export status
64sync tag testresult trusted unset update
65 )
66
67 local cmd="$words[1]"
68 if (( CURRENT == 1 )); then
69_describe -t commands 'monotone command' _mtn_cmds
70 else
71local curcontext="$curcontext"
72
73if [[ -n $cmd ]]; then
74 curcontext="${curcontext%:*:*}:mtn-${cmd}:"
75 _call_function ret _mtn_$cmd || _message 'no more arguments'
76else
77 _message "unknown monotone command: $cmd"
78fi
79return ret
80 fi
81}
82
83# define completion functions for each monotone command
84
85(( $+functions[_mtn_add] )) ||
86_mtn_add() {
87 _arguments -s : \
88'--unknown[add unknown files from workspace]'\
89'*:file to add:_mtn_files_unknown'
90}
91
92(( $+functions[_mtn_annotate] )) ||
93_mtn_annotate() {
94 _arguments -s : \
95{'(--revision)-r+','(-r)--revision='}'[select revision id for operation]:revision:_mtn_selector_or_revision'\
96'--brief[print a brief version of the normal output]'\
97'(*)*:file to annotate:_mtn_files_known'
98}
99
100(( $+functions[_mtn_approve] )) ||
101_mtn_approve() {
102 _arguments -s : \
103{'(--branch)-b+','(-b)--branch='}'[select branch cert for operation]:branch:_mtn_branches'\
104'(*)*:revision:_mtn_selector_or_revision'
105}
106
107# missing: asciik
108
109(( $+functions[_mtn_attr] )) ||
110_mtn_attr() {
111 if (( CURRENT == 2 )); then
112compadd -- set get drop
113 elif (( CURRENT == 3 )); then
114# fixme: should differentiate between set, get and drop
115compadd -- $(mtn automate attributes)
116 else
117local fname="$words[3]"
118compadd -- $(mtn automate attributes $fname)
119 fi
120}
121
122(( $+functions[_mtn_automate] )) ||
123_mtn_automate() {
124 (( $+_mtn_automate_cmds )) ||
125 _mtn_automate_cmds=(
126ancestors ancestry_difference attributes branches cert certs
127children common_ancestors content_diff db_get db_set
128descendents erase_ancestors genkey get_base_revision_id
129get_content_changed get_corresponding_path
130get_current_revision_id get_file get_file_of get_manifest_of
131get_option get_revision graph heads identify interface_version
132inventory keys leaves packet_for_fdata packet_for_fdelta
133packet_for_rdata packets_for_certs parents put_file
134put_revision select stdio tags toposort
135 )
136 if (( CURRENT == 2 )) ; then
137compadd -a _mtn_automate_cmds
138 fi
139}
140
141(( $+functions[_mtn_cat] )) ||
142_mtn_cat() {
143 _arguments -s : \
144{'(--revision)-r+','(-r)--revision='}'[select revision id for operation]:revision:_mtn_selector_or_revision'\
145'*:file to cat:_mtn_files_known'
146}
147
148(( $+functions[_mtn_cert] )) ||
149_mtn_cert() {
150 _arguments -s : \
151'1:revision:_mtn_selector_or_revision'\
152'2:certname: '\
153'3:certval: '
154}
155
156(( $+functions[_mtn_checkout] )) ||
157_mtn_checkout() {
158 _arguments -s : \
159{'(--branch)-b+','(-b)--branch='}'[select branch cert for operation]:branch:_mtn_branches'\
160{'(--revision)-r+','(-r)--revision='}'[select revision id for operation]:revision:_mtn_selector_or_revision'\
161'(*)*:directory for checkout: '
162}
163
164(( $+functions[_mtn_ci] )) ||
165_mtn_ci() {
166 _mtn_commit
167}
168
169# missing: clone
170
171(( $+functions[_mtn_co] )) ||
172_mtn_co() {
173 _mtn_checkout
174}
175
176(( $+functions[_mtn_comment] )) ||
177_mtn_comment() {
178 _arguments -s : \
179'1:revision:_mtn_selector_or_revision'\
180'2:comment: '
181}
182
183(( $+functions[_mtn_commit] )) ||
184_mtn_commit() {
185 _arguments -s : \
186{'(--branch)-b+','(-b)--branch='}'[select branch cert for operation]:branch:_mtn_branches'\
187{'(--message)-m+','(-m)--message='}'[set commit changelog message]:message: '\
188'--message-file=[set filename containing commit changelog message]:file:_files'\
189'--date=[override date/time for commit]:date: '\
190'--author=[override author for commit]:author: '\
191'--depth=[limit the number of levels of directories to descend]:depth'\
192'--exclude=[leave out anything described by its argument]:file:_mtn_files_known'\
193'*:files to commit:_mtn_files_changed'
194}
195
196(( $+functions[_mtn_complete] )) ||
197_mtn_complete() {
198 _arguments -s : \
199'1:what to complete:(file key manifest revision)'\
200'2:partial id: '
201}
202
203(( $+functions[_mtn_cvs_import] )) ||
204_mtn_cvs_import() {
205 _arguments : \
206'*:file:_files'
207}
208
209(( $+functions[_mtn_db] )) ||
210_mtn_db() {
211 (( $+_mtn_db_cmds )) ||
212 _mtn_db_cmds=(
213changesetify check dump execute info init
214kill_branch_certs_locally kill_rev_locally kill_tag_locally
215load migrate regenerate_caches rosterify set_epoch version
216 )
217 if (( CURRENT == 2 )) ; then
218compadd -a _mtn_db_cmds
219 fi
220}
221
222(( $+functions[_mtn_diff] )) ||
223_mtn_diff() {
224 _arguments -s : \
225{'(--revision)-r+','(-r)--revision='}'[select revision id for operation]:revision:_mtn_selector_or_revision'\
226'--depth=[limit the number of levels of directories to descend]:depth: '\
227'--exclude=[leave out anything described by its argument]:file:_mtn_files_known'\
228{'(--unified)-u','(-u)--unified'}'[use unified diff format]'\
229{'(--contex)-c','(-c)--contex'}'[use context diff format]'\
230'--external[use external diff hook for generating diffs]'\
231'--diff-args=[argument to pass external diff hook]:arg: '\
232{'-no-show-encloser','--no-show-c-function'}'[do not show the function containing each block of changes]'\
233'*:files to diff:_mtn_files_changed'
234}
235
236(( $+functions[_mtn_disapprove] )) ||
237_mtn_disapprove() {
238 _arguments -s : \
239{'(--branch)-b+','(-b)--branch='}'[select branch cert for operation]:branch:_mtn_branches'\
240'(*)*:revision to disapprove:_mtn_selector_or_revision'
241}
242
243(( $+functions[_mtn_drop] )) ||
244_mtn_drop() {
245 _arguments -s : \
246{'(--execute)-e','(-e)--execute'}'[perform the associated file operation]'\
247'--missing[perform the operations for files missing from workspace]'\
248{'(--recursive)-R','(-R)--recursive'}'[also operate on the contents of any listed directories]'\
249'*:entries to drop:_mtn_files_known'
250}
251
252(( $+functions[_mtn_dropkey] )) ||
253_mtn_dropkey() {
254 _mtn_keys
255}
256
257(( $+functions[_mtn_explicit_merge] )) ||
258_mtn_explicit_merge() {
259 _arguments -s : \
260'1:left revision:_mtn_selector_or_revision'\
261'2:right revision:_mtn_selector_or_revision'\
262'3:dest branch:_mtn_branches'
263}
264
265# missing: fdiff
266# missing: fload
267# missing: fmerge
268# missing: genkey
269# missing: get_roster
270
271(( $+functions[_mtn_heads] )) ||
272_mtn_heads() {
273 _arguments -s : \
274{'(--branch)-b+','(-b)--branch='}'[select branch cert for operation]:branch:_mtn_branches'
275}
276
277# missing: help
278# missing: identify
279# missing: import
280
281(( $+functions[_mtn_list] )) ||
282_mtn_list() {
283 (( $+_mtn_ls_cmds )) ||
284 _mtn_ls_cmds=(
285certs keys branches epochs tags vars
286known unknown ignored missing changed
287 )
288 if (( CURRENT == 2 )) ; then
289compadd -a _mtn_ls_cmds
290 fi
291}
292
293(( $+functions[_mtn_log] )) ||
294_mtn_log() {
295 _arguments -s : \
296{'(--revision)-r+','(-r)--revision='}'[select revision id for operation]:revision:_mtn_selector_or_revision'\
297'--last=[limit log output to the last number of entries]:last: ' \
298'--next=[limit log output to the next number of entries]:next: ' \
299'--brief[print a brief version of the normal output]'\
300'--diffs[print diffs along with logs]'\
301'--no-merges[exclude merges when printing logs]'\
302'--no-files[exclude files when printing logs]'\
303'*:restriction for log:_mtn_files_known'
304}
305
306(( $+functions[_mtn_ls] )) ||
307_mtn_ls() {
308 _mtn_list
309}
310
311(( $+functions[_mtn_merge] )) ||
312_mtn_merge() {
313 _arguments -s : \
314{'(--branch)-b+','(-b)--branch='}'[select branch cert for operation]:branch:_mtn_branches'\
315'--date=[override date/time for commit]:date: '\
316'--author=[override author for commit]:author: '
317}
318
319# missing: merge_into_dir
320# missing: merge_into_workspace
321
322(( $+functions[_mtn_mkdir] )) ||
323_mtn_mkdir() {
324 _arguments -s : \
325'--no-respect-ignore[do not ignore any files]'\
326'*:directory to create: '
327}
328
329(( $+functions[_mtn_mv] )) ||
330_mtn_mv() {
331 _mtn_rename
332}
333
334# missing: passphrase
335# missing: pivot_root
336# missing: pluck
337# missing: privkey
338
339(( $+functions[_mtn_propagate] )) ||
340_mtn_propagate() {
341 _arguments -s : \
342{'(--message)-m+','(-m)--message='}'[set commit changelog message]:message: '\
343'--message-file=[set filename containing commit changelog message]:file:_files'\
344'--date=[override date/time for commit]:date: '\
345'--author=[override author for commit]:author: '\
346'1:source branch:_mtn_branches'\
347'2:dest branch:_mtn_branches'\
348}
349
350# missing: pubkey
351
352(( $+functions[_mtn_pull] )) ||
353_mtn_pull() {
354 _arguments -s : \
355'--set-default[use the current arguments as the future default]'\
356'--exclude=[leave out anything described by its argument]:exclude: '
357}
358
359(( $+functions[_mtn_push] )) ||
360_mtn_push() {
361 _mtn_sync
362}
363
364(( $+functions[_mtn_rcs_import] )) ||
365_mtn_rcs_import() {
366 _arguments -s : \
367{'(--branch)-b+','(-b)--branch='}'[select branch cert for operation]:branch:_mtn_branches'\
368'*:files to import:_files'
369}
370
371# missing: read
372# missing: refresh_inodeprints
373
374(( $+functions[_mtn_rename] )) ||
375_mtn_rename() {
376 _arguments -s : \
377{'(--execute)-e','(-e)--execute'}'[perform the associated file operation]'\
378'*:files to rename:_mtn_files_known'
379}
380
381(( $+functions[_mtn_revert] )) ||
382_mtn_revert() {
383 _arguments -s : \
384'--depth=[limit the number of levels of directories to descend]:depth: '\
385'--exclude=[leave out anything described by its argument]:file:_mtn_files_known'\
386'--missing[perform the operations for files missing from workspace]'\
387'*:files to revert:_mtn_files_changed'
388}
389
390(( $+functions[_mtn_rm] )) ||
391_mtn_rm() {
392 _mtn_drop
393}
394
395(( $+functions[_mtn_serve] )) ||
396_mtn_serve() {
397 _arguments -s : \
398'--pid-file=[record process id of server]:file:_files'\
399'--exclude=[leave out anything described by its argument]:exclude: '\
400'--bind=[address:port to listen on]:bind: '\
401'--stdio[serve netsync on stdio]'\
402'--no-transport-auth[disable transport authentication]'\
403'*:pattern: '
404}
405
406# missing: set
407# missing: setup
408# missing: show_conflicts
409# missing: ssh_agent_add
410# missing: ssh_agent_export
411
412(( $+functions[_mtn_status] )) ||
413_mtn_status() {
414 _arguments -s : \
415'--depth=[limit the number of levels of directories to descend]:depth: '\
416'--exclude=[leave out anything described by its argument]:file:_mtn_files_known'\
417'*:file:_mtn_files_known'
418}
419
420(( $+functions[_mtn_sync] )) ||
421_mtn_sync() {
422 _arguments -s : \
423'--set-default[use the current arguments as the future default]'\
424'--exclude=[leave out anything described by its argument]:exclude: '\
425'--key-to-push=[push the specified key]:key: '
426}
427
428(( $+functions[_mtn_tag] )) ||
429_mtn_tag() {
430 _arguments -s : \
431'1:revision to tag:_mtn_selector_or_revision'\
432'(1)*:tagname: '
433}
434
435(( $+functions[_mtn_result] )) ||
436_mtn_testresult() {
437 _arguments -s : \
438'1:revision:_mtn_selector_or_revision'\
439'2:result:(pass fail true false yes no 1 0)'
440}
441
442# missing: trusted
443# missing: unset
444
445(( $+functions[_mtn_update] )) ||
446_mtn_update() {
447 _arguments -s : \
448{'(--branch)-b+','(-b)--branch='}'[select branch cert for operation]:branch:_mtn_branches'\
449{'(--revision)-r+','(-r)--revision='}'[select revision id for operation]:revision:_mtn_selector_or_revision'
450}
451
452
453# define completion functions for files maintained by monotone.
454
455(( $+functions[_mtn_files_unknown] )) ||
456_mtn_files_unknown() {
457 _mtn_files "unknown"
458}
459
460(( $+functions[_mtn_files_changed] )) ||
461_mtn_files_changed() {
462 _mtn_files "changed"
463}
464
465(( $+functions[_mtn_files_known] )) ||
466_mtn_files_known() {
467 _mtn_files "known"
468}
469
470(( $+functions[_mtn_files] )) ||
471_mtn_files() {
472 # "mtn ls --depth=0 foo ." should output the names of directories
473 # containing suppressed matches
474 local prefix=${PREFIX}X
475 local rcwd="$(_mtn_rcwd)"
476 local -a list
477 list=( ${${${(f)"$(mtn ls $1 ${prefix:h} 2>/dev/null)"}#$rcwd}#/} )
478 compadd -f -a list
479}
480
481(( $+functions[_mtn_branches] )) ||
482_mtn_branches() {
483 compadd -- $(mtn ls branches 2>/dev/null)
484}
485
486(( $+functions[_mtn_tags] )) ||
487_mtn_tags() {
488 compadd -- ${(u)${(f)"$(mtn ls tags 2>/dev/null)"}%% *}
489}
490
491(( $+functions[_mtn_public_keys] )) ||
492_mtn_public_keys() {
493 compadd -- ${${${(@M)${(f)"$(mtn ls keys 2>/dev/null)"}:#*@*}#* }%%* *}
494}
495
496(( $+functions[_mtn_keys] )) ||
497_mtn_keys() {
498 if [[ -n $PREFIX ]]; then
499compadd -X "(prefix of a) key id" -n \
500 -- $(mtn complete key $PREFIX 2>/dev/null)
501 fi
502}
503
504(( $+functions[_mtn_revisions] )) ||
505_mtn_revisions() {
506 if [[ -n $PREFIX ]]; then
507compadd -X "(prefix of a) revision id" -n \
508 -- $(mtn complete revision $PREFIX 2>/dev/null)
509 fi
510}
511
512(( $+functions[_mtn_selectors] )) ||
513_mtn_selectors() {
514 _values -s / -S : selector \
515'*b[branches]:branch:_mtn_branches' \
516'*h[branch heads]:branch head:_mtn_branches' \
517'*t[tags]:tag:_mtn_tags' \
518'*a[authors]:author:_mtn_public_keys' \
519'*d[date]:date:' \
520'*e[earlier than]:date:' \
521'*l[later than]:date:' \
522'*i[revision id]:revision id:_mtn_revisions'
523}
524
525(( $+functions[_mtn_selector_or_revision] )) ||
526_mtn_selector_or_revision() {
527 _alternative 'selector:selector:_mtn_selectors' \
528'revision:revision:_mtn_revisions'
529}
530
531# helper function, determines cwd relative to the root of the workspace
532
533(( $+functions[_mtn_rcwd] )) ||
534_mtn_rcwd() {
535 local current="$(pwd)"
536 local base=$current
537 while [[ "${base}" != "/" && ! -d "${base}/_MTN" ]]; do
538base=${base:h}
539 done
540 echo ${current#$base/}
541}
542
543_mtn "$@"

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status