#23 github: rewrite using arguments (properly sets context and allow extension)

This commit is contained in:
Julien Nicoulaud 2011-08-31 21:25:56 +02:00
parent ac42847bb2
commit 307ce5aafa
1 changed files with 43 additions and 27 deletions

68
_github
View File

@ -20,32 +20,48 @@
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
local -a _1st_arguments typeset -A opt_args
_1st_arguments=( local context state line curcontext="$curcontext"
'browse:Open this repo in a web browser'
'clone:Clone a repo' _github() {
'config:Automatically set configuration info, or pass args to specify' local ret=1
'create-from-local:Create a new GitHub repository from the current local repository'
'create:Create a new empty GitHub repository' _arguments -C \
'fetch:Fetch from a remote to a local branch' '1:cmd:->cmds' \
'fetch_all:Fetch all refs from a user' '*::arg:->args' \
'fork:Forks a GitHub repository' && ret=0
'home:Open this repos master branch in a web browser'
'ignore:Ignore a SHA from github network commits' case "$state" in
'info:Info about this project' (cmds)
'issues:Project issues tools' local commands; commands=(
'network:Project network tools - sub-commands : web [user], list, fetch, commits' 'admin:open this repo'\''s Admin panel a web browser'
'open:Open the given user/project in a web browser' 'browse:open this repo in a web browser'
'pull-request:Generate the text for a pull request' 'clone:clone a repo'
'pull:Pull from a remote' 'config:automatically set configuration info, or pass args to specify'
'search:Search GitHub for the given repository name' 'create:create a new, empty GitHub repository'
'track:Track another users repository' 'create-from-local:create a new GitHub repository from the current local repository'
'fetch:fetch from a remote to a local branch'
'fetch_all:fetch all refs from a user'
'fork:forks a GitHub repository'
'home:open this repo'\''s master branch in a web browser'
'ignore:ignore a SHA'
'info:info about this project'
'issues:project issues tools'
'network:project network tools'
'open:open the given user/project in a web browser'
'pull:pull from a remote'
'pull-request:generate the text for a pull request'
'search:search GitHub for the given repository name'
'track:track another user'\''s repository'
) )
_describe -t commands 'command' commands && ret=0
;;
(args)
curcontext="${curcontext%:*:*}:github-cmd-$words[1]:"
;;
esac
_arguments \ return ret
'*:: :->subcmds' && return 0 }
if (( CURRENT == 1 )); then _github "$@"
_describe -t commands "github subcommand" _1st_arguments
return
fi