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 '--confdir=[set location of configuration directory]:dir:_files -/'\
29 {'(--db)-d+','(-d)--db='}'[set name of database]:file:_files'\
30 '--debug[print debug log to stderr while running]'\
31 '--dump=[file to dump debugging log to, on failure]:file:_files'\
32 {'-h','--help'}'[display help message]'\
33 '--ignore-suspend-certs[do not ignore revisions marked as suspended]'\
34 {'(--key)-k+','(-k)--key='}'[set key for signatures]:keys keys:_mtn_keys'\
35 '--keydir=[set location of key store]:dir:_files -/'\
36 '--log=[file to write the log to]:file:_files'\
37 '--no-standard-rcfiles[do not load ~/.monotone/monotonerc or _MTN/monotonerc lua files]'\
38 '--no-builtin-rcfiles[do not load standard lua hooks]'\
39 '--quiet[suppress log and progress messages]'\
40 '--rcfile=[load extra rc file]:file:_files'\
41 '--reallyquiet[suppress warning, verbose, informational and progress messages]'\
42 '--root=[limit search for working copy to specified root]:dir:_files -/'\
43 '--ssh-sign=[sign with ssh-agent]:ssh_sign:(yes no check)'\
44 '--ticker=[set ticker style]:style:(count dot none)'\
45 '(- *)--version[print version number, then exit]'\
46 {'-@+','--xargs='}'[insert command line arguments taken from the given file]:file:_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 au automate cat cert checkout
57ci clone co comment commit complete cvs_import db diff
58disapprove drop dropkey explicit_merge fdiff fload fmerge
59genkey get_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
64suspend sync tag testresult trusted unset update version
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'--revs-only[annotate using full revision ids only]'\
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_au] )) ||
123_mtn_au() {
124 _mtn_automate
125}
126
127(( $+functions[_mtn_automate] )) ||
128_mtn_automate() {
129 (( $+_mtn_automate_cmds )) ||
130 _mtn_automate_cmds=(
131ancestors ancestry_difference branches cert certs children
132common_ancestors content_diff db_get db_set descendents
133drop_attribute erase_ancestors genkey get_attributes
134get_base_revision_id get_content_changed
135get_corresponding_path get_current_revision_id get_file
136get_file_of get_manifest_of get_option get_revision graph
137heads identify interface_version inventory keys leaves
138packet_for_fdata packet_for_fdelta packet_for_rdata
139packets_for_certs parents put_file put_revision roots select
140set_attribute stdio tags toposort
141 )
142 if (( CURRENT == 2 )) ; then
143compadd -a _mtn_automate_cmds
144 fi
145}
146
147(( $+functions[_mtn_cat] )) ||
148_mtn_cat() {
149 _arguments -s : \
150{'(--revision)-r+','(-r)--revision='}'[select revision id for operation]:revision:_mtn_selector_or_revision'\
151'*:file to cat:_mtn_files_known'
152}
153
154(( $+functions[_mtn_cert] )) ||
155_mtn_cert() {
156 _arguments -s : \
157'1:revision:_mtn_selector_or_revision'\
158'2:certname: '\
159'3:certval: '
160}
161
162(( $+functions[_mtn_checkout] )) ||
163_mtn_checkout() {
164 _arguments -s : \
165{'(--branch)-b+','(-b)--branch='}'[select branch cert for operation]:branch:_mtn_branches'\
166{'(--revision)-r+','(-r)--revision='}'[select revision id for operation]:revision:_mtn_selector_or_revision'\
167'(*)*:directory for checkout: '
168}
169
170(( $+functions[_mtn_ci] )) ||
171_mtn_ci() {
172 _mtn_commit
173}
174
175# missing: clone
176
177(( $+functions[_mtn_co] )) ||
178_mtn_co() {
179 _mtn_checkout
180}
181
182(( $+functions[_mtn_comment] )) ||
183_mtn_comment() {
184 _arguments -s : \
185'1:revision:_mtn_selector_or_revision'\
186'2:comment: '
187}
188
189(( $+functions[_mtn_commit] )) ||
190_mtn_commit() {
191 _arguments -s : \
192{'(--branch)-b+','(-b)--branch='}'[select branch cert for operation]:branch:_mtn_branches'\
193{'(--message)-m+','(-m)--message='}'[set commit changelog message]:message: '\
194'--message-file=[set filename containing commit changelog message]:file:_files'\
195'--date=[override date/time for commit]:date: '\
196'--author=[override author for commit]:author: '\
197'--depth=[limit the number of levels of directories to descend]:depth'\
198'--exclude=[leave out anything described by its argument]:file:_mtn_files_known'\
199'*:files to commit:_mtn_files_changed'
200}
201
202(( $+functions[_mtn_complete] )) ||
203_mtn_complete() {
204 _arguments -s : \
205'1:what to complete:(file key manifest revision)'\
206'2:partial id: '
207}
208
209(( $+functions[_mtn_cvs_import] )) ||
210_mtn_cvs_import() {
211 _arguments : \
212'*:file:_files'
213}
214
215(( $+functions[_mtn_db] )) ||
216_mtn_db() {
217 (( $+_mtn_db_cmds )) ||
218 _mtn_db_cmds=(
219changesetify check dump execute info init
220kill_branch_certs_locally kill_rev_locally kill_tag_locally
221load migrate regenerate_caches rosterify set_epoch version
222 )
223 if (( CURRENT == 2 )) ; then
224compadd -a _mtn_db_cmds
225 fi
226}
227
228(( $+functions[_mtn_diff] )) ||
229_mtn_diff() {
230 _arguments -s : \
231{'(--revision)-r+','(-r)--revision='}'[select revision id for operation]:revision:_mtn_selector_or_revision'\
232'--depth=[limit the number of levels of directories to descend]:depth: '\
233'--exclude=[leave out anything described by its argument]:file:_mtn_files_known'\
234{'(--unified)-u','(-u)--unified'}'[use unified diff format]'\
235{'(--contex)-c','(-c)--contex'}'[use context diff format]'\
236'--external[use external diff hook for generating diffs]'\
237'--diff-args=[argument to pass external diff hook]:arg: '\
238{'-no-show-encloser','--no-show-c-function'}'[do not show the function containing each block of changes]'\
239'*:files to diff:_mtn_files_changed'
240}
241
242(( $+functions[_mtn_disapprove] )) ||
243_mtn_disapprove() {
244 _arguments -s : \
245{'(--branch)-b+','(-b)--branch='}'[select branch cert for operation]:branch:_mtn_branches'\
246'(*)*:revision to disapprove:_mtn_selector_or_revision'
247}
248
249(( $+functions[_mtn_drop] )) ||
250_mtn_drop() {
251 _arguments -s : \
252{'(--execute)-e','(-e)--execute'}'[perform the associated file operation]'\
253'--missing[perform the operations for files missing from workspace]'\
254{'(--recursive)-R','(-R)--recursive'}'[also operate on the contents of any listed directories]'\
255'*:entries to drop:_mtn_files_known'
256}
257
258(( $+functions[_mtn_dropkey] )) ||
259_mtn_dropkey() {
260 _mtn_keys
261}
262
263(( $+functions[_mtn_explicit_merge] )) ||
264_mtn_explicit_merge() {
265 _arguments -s : \
266'1:left revision:_mtn_selector_or_revision'\
267'2:right revision:_mtn_selector_or_revision'\
268'3:dest branch:_mtn_branches'
269}
270
271# missing: fdiff
272# missing: fload
273# missing: fmerge
274# missing: genkey
275# missing: get_roster
276
277(( $+functions[_mtn_heads] )) ||
278_mtn_heads() {
279 _arguments -s : \
280{'(--branch)-b+','(-b)--branch='}'[select branch cert for operation]:branch:_mtn_branches'
281}
282
283# missing: help
284# missing: identify
285# missing: import
286
287(( $+functions[_mtn_list] )) ||
288_mtn_list() {
289 (( $+_mtn_ls_cmds )) ||
290 _mtn_ls_cmds=(
291certs keys branches epochs tags vars
292known unknown ignored missing changed
293 )
294 if (( CURRENT == 2 )) ; then
295compadd -a _mtn_ls_cmds
296 fi
297}
298
299(( $+functions[_mtn_log] )) ||
300_mtn_log() {
301 _arguments -s : \
302{'(--revision)-r+','(-r)--revision='}'[select revision id for operation]:revision:_mtn_selector_or_revision'\
303'--last=[limit log output to the last number of entries]:last: ' \
304'--next=[limit log output to the next number of entries]:next: ' \
305'--brief[print a brief version of the normal output]'\
306'--diffs[print diffs along with logs]'\
307'--no-merges[exclude merges when printing logs]'\
308'--no-files[exclude files when printing logs]'\
309'*:restriction for log:_mtn_files_known'
310}
311
312(( $+functions[_mtn_ls] )) ||
313_mtn_ls() {
314 _mtn_list
315}
316
317(( $+functions[_mtn_merge] )) ||
318_mtn_merge() {
319 _arguments -s : \
320{'(--branch)-b+','(-b)--branch='}'[select branch cert for operation]:branch:_mtn_branches'\
321'--date=[override date/time for commit]:date: '\
322'--author=[override author for commit]:author: '
323}
324
325# missing: merge_into_dir
326# missing: merge_into_workspace
327
328(( $+functions[_mtn_mkdir] )) ||
329_mtn_mkdir() {
330 _arguments -s : \
331'--no-respect-ignore[do not ignore any files]'\
332'*:directory to create: '
333}
334
335(( $+functions[_mtn_mv] )) ||
336_mtn_mv() {
337 _mtn_rename
338}
339
340# missing: passphrase
341# missing: pivot_root
342# missing: pluck
343# missing: privkey
344
345(( $+functions[_mtn_propagate] )) ||
346_mtn_propagate() {
347 _arguments -s : \
348{'(--message)-m+','(-m)--message='}'[set commit changelog message]:message: '\
349'--message-file=[set filename containing commit changelog message]:file:_files'\
350'--date=[override date/time for commit]:date: '\
351'--author=[override author for commit]:author: '\
352'1:source branch:_mtn_branches'\
353'2:dest branch:_mtn_branches'\
354}
355
356# missing: pubkey
357
358(( $+functions[_mtn_pull] )) ||
359_mtn_pull() {
360 _arguments -s : \
361'--set-default[use the current arguments as the future default]'\
362'--exclude=[leave out anything described by its argument]:exclude: '
363}
364
365(( $+functions[_mtn_push] )) ||
366_mtn_push() {
367 _mtn_sync
368}
369
370(( $+functions[_mtn_rcs_import] )) ||
371_mtn_rcs_import() {
372 _arguments -s : \
373{'(--branch)-b+','(-b)--branch='}'[select branch cert for operation]:branch:_mtn_branches'\
374'*:files to import:_files'
375}
376
377# missing: read
378# missing: refresh_inodeprints
379
380(( $+functions[_mtn_rename] )) ||
381_mtn_rename() {
382 _arguments -s : \
383{'(--execute)-e','(-e)--execute'}'[perform the associated file operation]'\
384'*:files to rename:_mtn_files_known'
385}
386
387(( $+functions[_mtn_revert] )) ||
388_mtn_revert() {
389 _arguments -s : \
390'--depth=[limit the number of levels of directories to descend]:depth: '\
391'--exclude=[leave out anything described by its argument]:file:_mtn_files_known'\
392'--missing[perform the operations for files missing from workspace]'\
393'*:files to revert:_mtn_files_changed'
394}
395
396(( $+functions[_mtn_rm] )) ||
397_mtn_rm() {
398 _mtn_drop
399}
400
401(( $+functions[_mtn_serve] )) ||
402_mtn_serve() {
403 _arguments -s : \
404'--pid-file=[record process id of server]:file:_files'\
405'--exclude=[leave out anything described by its argument]:exclude: '\
406'--bind=[address:port to listen on]:bind: '\
407'--stdio[serve netsync on stdio]'\
408'--no-transport-auth[disable transport authentication]'\
409'*:pattern: '
410}
411
412# missing: set
413# missing: setup
414# missing: show_conflicts
415# missing: ssh_agent_add
416# missing: ssh_agent_export
417
418(( $+functions[_mtn_status] )) ||
419_mtn_status() {
420 _arguments -s : \
421'--depth=[limit the number of levels of directories to descend]:depth: '\
422'--exclude=[leave out anything described by its argument]:file:_mtn_files_known'\
423'*:file:_mtn_files_known'
424}
425
426# missing: suspend
427
428(( $+functions[_mtn_sync] )) ||
429_mtn_sync() {
430 _arguments -s : \
431'--set-default[use the current arguments as the future default]'\
432'--exclude=[leave out anything described by its argument]:exclude: '\
433'--key-to-push=[push the specified key]:key: '
434}
435
436(( $+functions[_mtn_tag] )) ||
437_mtn_tag() {
438 _arguments -s : \
439'1:revision to tag:_mtn_selector_or_revision'\
440'(1)*:tagname: '
441}
442
443(( $+functions[_mtn_result] )) ||
444_mtn_testresult() {
445 _arguments -s : \
446'1:revision:_mtn_selector_or_revision'\
447'2:result:(pass fail true false yes no 1 0)'
448}
449
450# missing: trusted
451# missing: unset
452
453(( $+functions[_mtn_update] )) ||
454_mtn_update() {
455 _arguments -s : \
456{'(--branch)-b+','(-b)--branch='}'[select branch cert for operation]:branch:_mtn_branches'\
457{'(--revision)-r+','(-r)--revision='}'[select revision id for operation]:revision:_mtn_selector_or_revision'
458}
459
460(( $+functions[_mtn_version] )) ||
461_mtn_version() {
462 _arguments -s : \
463'--verbose[print detailed version number]'
464}
465
466# define completion functions for files maintained by monotone.
467
468(( $+functions[_mtn_files_unknown] )) ||
469_mtn_files_unknown() {
470 _mtn_files "unknown"
471}
472
473(( $+functions[_mtn_files_changed] )) ||
474_mtn_files_changed() {
475 _mtn_files "changed"
476}
477
478(( $+functions[_mtn_files_known] )) ||
479_mtn_files_known() {
480 _mtn_files "known"
481}
482
483(( $+functions[_mtn_files] )) ||
484_mtn_files() {
485 # "mtn ls --depth=0 foo ." should output the names of directories
486 # containing suppressed matches
487 local prefix=${PREFIX}X
488 local rcwd="$(_mtn_rcwd)"
489 local -a list
490 list=( ${${${(f)"$(mtn ls --no-pager $1 ${prefix:h} 2>/dev/null)"}#$rcwd}#/} )
491 compadd -f -a list
492}
493
494(( $+functions[_mtn_branches] )) ||
495_mtn_branches() {
496 compadd -- $(mtn ls --no-pager branches 2>/dev/null)
497}
498
499(( $+functions[_mtn_tags] )) ||
500_mtn_tags() {
501 compadd -- ${(u)${(f)"$(mtn ls --no-pager tags 2>/dev/null)"}%% *}
502}
503
504(( $+functions[_mtn_public_keys] )) ||
505_mtn_public_keys() {
506 compadd -- ${${${(@M)${(f)"$(mtn ls --no-pager keys 2>/dev/null)"}:#*@*}#* }%%* *}
507}
508
509(( $+functions[_mtn_keys] )) ||
510_mtn_keys() {
511 if [[ -n $PREFIX ]]; then
512compadd -X "(prefix of a) key id" -n \
513 -- $(mtn complete key $PREFIX 2>/dev/null)
514 fi
515}
516
517(( $+functions[_mtn_revisions] )) ||
518_mtn_revisions() {
519 if [[ -n $PREFIX ]]; then
520compadd -X "(prefix of a) revision id" -n \
521 -- $(mtn complete revision $PREFIX 2>/dev/null)
522 fi
523}
524
525(( $+functions[_mtn_selectors] )) ||
526_mtn_selectors() {
527 _values -s / -S : selector \
528'*b[branches]:branch:_mtn_branches' \
529'*h[branch heads]:branch head:_mtn_branches' \
530'*t[tags]:tag:_mtn_tags' \
531'*a[authors]:author:_mtn_public_keys' \
532'*d[date]:date:' \
533'*e[earlier than]:date:' \
534'*l[later than]:date:' \
535'*i[revision id]:revision id:_mtn_revisions' \
536'*p[parent of]:revision_id:_mtn_revisions'
537}
538
539(( $+functions[_mtn_selector_or_revision] )) ||
540_mtn_selector_or_revision() {
541 _alternative 'selector:selector:_mtn_selectors' \
542'revision:revision:_mtn_revisions'
543}
544
545# helper function, determines cwd relative to the root of the workspace
546
547(( $+functions[_mtn_rcwd] )) ||
548_mtn_rcwd() {
549 local current="$(pwd)"
550 local base=$current
551 while [[ "${base}" != "/" && ! -d "${base}/_MTN" ]]; do
552base=${base:h}
553 done
554 echo ${current#$base/}
555}
556
557_mtn "$@"

Archive Download this file

Branches

Tags

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