2011-08-31 19:14:45 +00:00
|
|
|
#compdef github gh
|
2011-07-21 22:50:51 +00:00
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Description
|
|
|
|
# -----------
|
|
|
|
#
|
2011-08-31 19:33:47 +00:00
|
|
|
# Completion script for Github gem 0.6.2 (https://github.com/defunkt/github-gem).
|
2011-07-21 22:50:51 +00:00
|
|
|
#
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Authors
|
|
|
|
# -------
|
|
|
|
#
|
2011-08-31 19:14:45 +00:00
|
|
|
# * Julien Nicoulaud (https://github.com/nicoulaj)
|
2011-07-21 22:50:51 +00:00
|
|
|
#
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
|
|
|
# vim: ft=zsh sw=2 ts=2 et
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
2011-08-31 19:25:56 +00:00
|
|
|
typeset -A opt_args
|
|
|
|
local context state line curcontext="$curcontext"
|
2011-07-21 22:50:51 +00:00
|
|
|
|
2011-08-31 19:25:56 +00:00
|
|
|
_github() {
|
|
|
|
local ret=1
|
2011-07-21 22:50:51 +00:00
|
|
|
|
2011-08-31 19:25:56 +00:00
|
|
|
_arguments -C \
|
|
|
|
'1:cmd:->cmds' \
|
|
|
|
'*::arg:->args' \
|
|
|
|
&& ret=0
|
|
|
|
|
|
|
|
case "$state" in
|
|
|
|
(cmds)
|
|
|
|
local commands; commands=(
|
|
|
|
'admin:open this repo'\''s Admin panel a web browser'
|
|
|
|
'browse:open this repo in a web browser'
|
|
|
|
'clone:clone a repo'
|
|
|
|
'config:automatically set configuration info, or pass args to specify'
|
|
|
|
'create:create a new, empty GitHub 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]:"
|
2011-08-31 19:33:18 +00:00
|
|
|
case $words[1] in
|
2011-08-31 19:37:22 +00:00
|
|
|
(admin|fetch|fetch_all|home|info)
|
|
|
|
_message 'no more arguments' && ret=0
|
2011-08-31 19:33:18 +00:00
|
|
|
;;
|
|
|
|
(browse)
|
2011-09-02 08:30:28 +00:00
|
|
|
_arguments \
|
|
|
|
'1: :_github_users' \
|
|
|
|
'2: :_github_branches' \
|
|
|
|
&& ret=0
|
2011-08-31 19:33:18 +00:00
|
|
|
;;
|
|
|
|
(clone)
|
2011-09-02 08:35:25 +00:00
|
|
|
_arguments \
|
|
|
|
'1: :_github_users' \
|
|
|
|
'2: :_github_repos' \
|
|
|
|
'3: :_files -/' \
|
|
|
|
'--search[search for user or repo and clone selected repository]:user or repo' \
|
|
|
|
'--ssh[clone using the git@github.com style url]' \
|
|
|
|
&& ret=0
|
2011-08-31 19:33:18 +00:00
|
|
|
;;
|
|
|
|
(config)
|
2011-09-02 08:36:39 +00:00
|
|
|
_arguments \
|
|
|
|
'1: :_github_users' \
|
|
|
|
'2: :_github_repos' \
|
|
|
|
&& ret=0
|
2011-08-31 19:33:18 +00:00
|
|
|
;;
|
|
|
|
(create)
|
2011-09-02 08:40:17 +00:00
|
|
|
_arguments \
|
|
|
|
'1:repo name' \
|
|
|
|
'--markdown[create README.markdown]' \
|
|
|
|
'--mdown[create README.mdown]' \
|
|
|
|
'--private[create private repository]' \
|
|
|
|
'--rdoc[create README.rdoc]' \
|
|
|
|
'--rst[create README.rst]' \
|
|
|
|
'--textile[create README.textile]' \
|
|
|
|
&& ret=0
|
2011-08-31 19:33:18 +00:00
|
|
|
;;
|
|
|
|
(create-from-local)
|
2011-09-02 08:41:22 +00:00
|
|
|
_arguments \
|
|
|
|
'--private[create private repository]' \
|
|
|
|
&& ret=0
|
2011-08-31 19:33:18 +00:00
|
|
|
;;
|
|
|
|
(fork)
|
2011-09-02 12:58:44 +00:00
|
|
|
_arguments \
|
|
|
|
'1: :_github_user_slash_repos' \
|
|
|
|
&& ret=0
|
2011-08-31 19:33:18 +00:00
|
|
|
;;
|
|
|
|
(ignore)
|
2011-09-02 13:03:46 +00:00
|
|
|
_arguments \
|
|
|
|
'1: :_github_network_commits' \
|
|
|
|
&& ret=0
|
2011-08-31 19:33:18 +00:00
|
|
|
;;
|
|
|
|
(issues)
|
2011-09-02 13:11:17 +00:00
|
|
|
_arguments \
|
|
|
|
'1:cmd:->cmds' \
|
|
|
|
'2:: :_github_users' \
|
|
|
|
'--after[only show issues updated after a certain date]:date' \
|
|
|
|
'--label[only show issues with a certain label]:label' \
|
|
|
|
&& ret=0
|
|
|
|
case "$state" in
|
|
|
|
(cmds)
|
|
|
|
local statuses; statuses=(
|
|
|
|
'open:show open issues'
|
|
|
|
'closed:show closed issues'
|
|
|
|
)
|
|
|
|
_describe -t statuses 'status' statuses && ret=0
|
|
|
|
;;
|
|
|
|
esac
|
2011-08-31 19:33:18 +00:00
|
|
|
;;
|
|
|
|
(network)
|
|
|
|
# TODO Not implemented
|
|
|
|
_message "${words[1]} command argument" && ret=0
|
|
|
|
;;
|
|
|
|
(open)
|
|
|
|
# TODO Not implemented
|
|
|
|
_message "${words[1]} command argument" && ret=0
|
|
|
|
;;
|
|
|
|
(pull)
|
|
|
|
# TODO Not implemented
|
|
|
|
_message "${words[1]} command argument" && ret=0
|
|
|
|
;;
|
|
|
|
(pull-request)
|
|
|
|
# TODO Not implemented
|
|
|
|
_message "${words[1]} command argument" && ret=0
|
|
|
|
;;
|
|
|
|
(search)
|
|
|
|
# TODO Not implemented
|
|
|
|
_message "${words[1]} command argument" && ret=0
|
|
|
|
;;
|
|
|
|
(track)
|
|
|
|
# TODO Not implemented
|
|
|
|
_message "${words[1]} command argument" && ret=0
|
|
|
|
;;
|
|
|
|
esac
|
2011-08-31 19:25:56 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
return ret
|
|
|
|
}
|
|
|
|
|
2011-09-02 08:30:28 +00:00
|
|
|
(( $+functions[_github_users] )) ||
|
|
|
|
_github_users() {
|
|
|
|
# TODO Not implemented
|
|
|
|
_message -e users 'user'
|
|
|
|
}
|
|
|
|
|
2011-09-02 08:35:25 +00:00
|
|
|
(( $+functions[_github_repos] )) ||
|
|
|
|
_github_repos() {
|
|
|
|
# TODO Not implemented
|
|
|
|
_message -e repos 'repo'
|
|
|
|
}
|
|
|
|
|
2011-09-02 08:30:28 +00:00
|
|
|
(( $+functions[_github_branches] )) ||
|
|
|
|
_github_branches() {
|
|
|
|
# TODO Not implemented
|
|
|
|
_message -e branches 'branch'
|
|
|
|
}
|
|
|
|
|
2011-09-02 12:58:44 +00:00
|
|
|
(( $+functions[_github_user_slash_repos] )) ||
|
|
|
|
_github_user_slash_repos() {
|
|
|
|
local ret=1
|
|
|
|
if compset -P '*/'; then
|
|
|
|
# TODO Make it contextual to the user
|
|
|
|
_wanted repos expl 'repo' _github_repos && ret=0
|
|
|
|
else
|
|
|
|
_wanted users expl 'user' _github_users -qS/ && ret=0
|
|
|
|
fi
|
|
|
|
return ret
|
|
|
|
}
|
|
|
|
|
2011-09-02 13:03:46 +00:00
|
|
|
(( $+functions[_github_network_commits] )) ||
|
|
|
|
_github_network_commits() {
|
|
|
|
# TODO Not implemented (use 'github network commits' output)
|
|
|
|
_message -e commits 'commit'
|
|
|
|
}
|
|
|
|
|
2011-08-31 19:25:56 +00:00
|
|
|
_github "$@"
|