workdir: override cmd_branch
[yap.git] / yap.zsh
blobf95c5210ce4a3db277dc79a359cd703cc08bf726
2 _yap-commands () {
3 local -a commands
5 commands=(
6 'add:add a new file to the repository'
7 'branch:list, create, or delete branches'
8 'cherry-pick:apply the changes in a given commit to the current branch'
9 'clone:make a local copy of an existing repository'
10 'commit:record changes to files as a new commit'
11 'diff:show staged, unstaged, or all uncommitted changes'
12 'fetch:retrieve commits from a remote repository'
13 'history:alter history by dropping or amending commits'
14 'init:turn a directory into a repository'
15 'log:show the changelog for particular versions or files'
16 'merge:merge a branch into the current branch'
17 'plugins:show information about loaded plugins'
18 'point:move the current branch to a different revision'
19 'push:send local commits to a remote repository'
20 'repo:list, add, or delete configured remote repositories'
21 'revert:remove uncommitted changes from a file (*)'
22 'resolved:mark files with conflicts as resolved'
23 'rm:delete a file from the repository'
24 'show:show the changes introduced by a given commit'
25 'stage:stage changes in a file for commit'
26 'status:show files with staged and unstaged changes'
27 'switch:change the current working branch'
28 'track:query and configure remote branch tracking'
29 'uncommit:reverse the actions of the last commit'
30 'unstage:unstage changes in a file'
31 'update:update the current branch relative to its tracking branch'
32 'version:report the current version of yap'
35 _describe -t commands 'zsh command' commands && ret=0
38 _yap-unstage () {
39 _arguments \
40 '*:file:_files' && ret=0
43 _yap-stage () {
44 _arguments \
45 '*:file:_files' && ret=0
48 _yap-add () {
49 _arguments \
50 '*:file:_files' && ret=0
53 _yap-rm () {
54 _arguments \
55 '*:file:_files' && ret=0
58 _yap-log () {
59 _arguments \
60 '*:file:_files' && ret=0
63 _yap-resolved () {
64 _arguments \
65 '*:file:_files' && ret=0
68 _yap-switch () {
69 _arguments \
70 '*:branch:__git_heads' && ret=0
73 _yap-branch () {
74 _arguments \
75 '-d[delete a branch]:local branch' \
76 '*:branch:__git_heads' && ret=0
79 _yap-commit () {
80 _arguments \
81 '(-d)-a[commit all changes]' \
82 '(-a)-d[commit only staged changes]' \
83 '-m[specify commit message]:commit message' && ret=0
86 _yap-diff () {
87 _arguments \
88 '(-u)-d[show only staged changes]' \
89 '(-d)-u[show only unstaged changes]' && ret=0
92 __yap_repos () {
93 repos=( `yap repo | gawk '{print $1}'` )
94 compadd - "${repos[@]}"
97 _yap-repo () {
98 _arguments \
99 '-d[delete a repository]' \
100 ':repo:__yap_repos' \
101 '*:url' && ret=0
104 _yap-fetch () {
105 _arguments \
106 ':repo:__yap_repos' && ret=0
109 _yap-log () {
110 _arguments \
111 '-r:revision:__git_heads' \
112 '*:files:_files' && ret=0
115 _yap-merge () {
116 _arguments \
117 ':branch:__git_heads' && ret=0
120 _yap-push () {
121 _arguments \
122 ':repo:__yap_repos' \
123 ':branch:__git_heads' && ret=0
126 _yap-track () {
127 _arguments \
128 ':repo:__yap_repos' \
129 ':branch:__git_heads' && ret=0
132 _yap () {
133 if (( CURRENT == 2 )); then
134 _yap-commands
135 else
136 shift words
137 (( CURRENT-- ))
138 curcontext="${curcontext%:*:*}:yap-$words[1]:"
139 _call_function ret _yap-$words[1]
143 compdef _yap yap