]> git.madduck.net Git - code/vcsh.git/blob - _vcsh

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

_vcsh: Remove stale completion
[code/vcsh.git] / _vcsh
1 #compdef vcsh
2
3 function __vcsh_repositories () {
4         local expl
5         local -a repos
6         repos=( ${(f)"$(command vcsh list)"} )
7         _describe -t repos 'repositories' repos
8 }
9
10 function __vcsh_not_implemented_yet () {
11         _message "Subcommand completion '${1#*-}': not implemented yet"
12 }
13
14 function _vcsh-clone () {
15         __vcsh_not_implemented_yet "$0" #TODO
16 }
17
18 function _vcsh-delete () {
19         (( CURRENT == 2 )) && __vcsh_repositories
20 }
21
22 function _vcsh-enter () {
23         (( CURRENT == 2 )) && __vcsh_repositories
24 }
25
26 function _vcsh-help () {
27         _nothing
28 }
29
30 function _vcsh-init () {
31         _nothing
32 }
33
34 function _vcsh-list () {
35         _nothing
36 }
37
38 function _vcsh-list-tracked () {
39         (( CURRENT == 2 )) && __vcsh_repositories
40 }
41
42 function _vcsh-list-untracked () {
43         _nothing
44 }
45
46 function _vcsh-pull () {
47         _nothing
48 }
49
50 function _vcsh-push () {
51         _nothing
52 }
53
54 function _vcsh-rename () {
55         (( CURRENT == 2 )) && __vcsh_repositories
56         (( CURRENT == 3 )) && _message "new repository name"
57         (( CURRENT > 3 )) && _nothing
58 }
59
60 function _vcsh-run () {
61         (( CURRENT == 2 )) && __vcsh_repositories
62         if (( CURRENT >= 3 )); then
63                 words=( "${(@)words[3,-1]}" )
64                 (( CURRENT -= 2 ))
65                 _complete
66         fi
67 }
68
69 function _vcsh-status () {
70         (( CURRENT == 2 )) && __vcsh_repositories
71 }
72
73 function _vcsh-upgrade () {
74         (( CURRENT == 2 )) && __vcsh_repositories
75 }
76
77 function _vcsh-version () {
78         _nothing
79 }
80
81 function _vcsh-which () {
82         _files
83 }
84
85 function _vcsh-write-gitignore () {
86         (( CURRENT == 2 )) && __vcsh_repositories
87 }
88
89 function _vcsh () {
90         local curcontext="${curcontext}"
91         local state vcshcommand
92         local -a args subcommands
93
94         subcommands=(
95                 "clone:clone an existing repository"
96                 "commit:commit in all repositories"
97                 "delete:delete an existing repository"
98                 "enter:enter repository; spawn new <\$SHELL>"
99                 "help:display help"
100                 "init:initialize an empty repository"
101                 "list:list all local vcsh repositories"
102                 "list-tracked:list all files tracked by vcsh"
103                 "list-tracked-by:list files tracked by a repository"
104                 "list-untracked:list all files not tracked by vcsh"
105                 "pull:pull from all vcsh remotes"
106                 "push:push to vcsh remotes"
107                 "rename:rename a repository"
108                 "run:run command with <\$GIT_DIR> and <\$GIT_WORK_TREE> set"
109                 "status:show statuses of all/one vcsh repositories"
110                 "upgrade:upgrade repository to currently recommended settings"
111                 "version:print version information"
112                 "which:find <substring> in name of any tracked file"
113                 "write-gitignore:write .gitignore.d/<repo> via git ls-files"
114         )
115
116         args=(
117                 '-c[source <file> prior to other configuration files]:config files:_path_files'
118                 '-d[enable debug mode]'
119                 '-v[enable verbose mode]'
120                 '*:: :->subcommand_or_options_or_repo'
121         )
122
123         _arguments -C ${args} && return
124
125         if [[ ${state} == "subcommand_or_options_or_repo" ]]; then
126                 if (( CURRENT == 1 )); then
127                         _describe -t subcommands 'vcsh sub-commands' subcommands
128                         __vcsh_repositories
129                 else
130                         vcshcommand="${words[1]}"
131                         if ! (( ${+functions[_vcsh-$vcshcommand]} )); then
132                                 # There is no handler function, so this is probably the name
133                                 # of a repository. Act accordingly.
134                                 _dispatch git git
135                         else
136                                 curcontext="${curcontext%:*:*}:vcsh-${vcshcommand}:"
137                                 _call_function ret _vcsh-${vcshcommand}
138                         fi
139                 fi
140         fi
141 }
142
143 _vcsh "$@"