zsh-completions/_github

164 lines
4.7 KiB
Plaintext

#compdef github gh
# ------------------------------------------------------------------------------
# Description
# -----------
#
# Completion script for Github gem 0.6.2 (https://github.com/defunkt/github-gem).
#
# ------------------------------------------------------------------------------
# Authors
# -------
#
# * Julien Nicoulaud (https://github.com/nicoulaj)
#
# ------------------------------------------------------------------------------
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
# ------------------------------------------------------------------------------
typeset -A opt_args
local context state line curcontext="$curcontext"
_github() {
local ret=1
_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]:"
case $words[1] in
(admin|fetch|fetch_all|home|info)
_message 'no more arguments' && ret=0
;;
(browse)
_arguments \
'1: :_github_users' \
'2: :_github_branches' \
&& ret=0
;;
(clone)
_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
;;
(config)
_arguments \
'1: :_github_users' \
'2: :_github_repos' \
&& ret=0
;;
(create)
_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
;;
(create-from-local)
# TODO Not implemented
_message "${words[1]} command argument" && ret=0
;;
(fork)
# TODO Not implemented
_message "${words[1]} command argument" && ret=0
;;
(home)
# TODO Not implemented
_message "${words[1]} command argument" && ret=0
;;
(ignore)
# TODO Not implemented
_message "${words[1]} command argument" && ret=0
;;
(issues)
# TODO Not implemented
_message "${words[1]} command argument" && ret=0
;;
(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
;;
esac
return ret
}
(( $+functions[_github_users] )) ||
_github_users() {
# TODO Not implemented
_message -e users 'user'
}
(( $+functions[_github_repos] )) ||
_github_repos() {
# TODO Not implemented
_message -e repos 'repo'
}
(( $+functions[_github_branches] )) ||
_github_branches() {
# TODO Not implemented
_message -e branches 'branch'
}
_github "$@"