Compare commits
21 Commits
044b8788e4
...
ee3d08d601
| Author | SHA1 | Date |
|---|---|---|
|
|
ee3d08d601 | |
|
|
ce3bdfed22 | |
|
|
fe94956940 | |
|
|
b5da595150 | |
|
|
7ea6b7a971 | |
|
|
32210c83c5 | |
|
|
867fb5a09c | |
|
|
5359bbf0e7 | |
|
|
a3e89f7c56 | |
|
|
cf57a3266c | |
|
|
41896a6013 | |
|
|
0d8667bb6a | |
|
|
79c6d1715f | |
|
|
f5e58a5ca7 | |
|
|
6c8cd1b111 | |
|
|
eb711299c5 | |
|
|
d71c3c84cc | |
|
|
c3f1f7748d | |
|
|
45fd6f398a | |
|
|
26b538f012 | |
|
|
fd43209f3a |
|
|
@ -69,3 +69,10 @@ esac
|
|||
|
||||
return $ret
|
||||
|
||||
# Local Variables:
|
||||
# mode: Shell-Script
|
||||
# sh-indentation: 2
|
||||
# indent-tabs-mode: nil
|
||||
# sh-basic-offset: 2
|
||||
# End:
|
||||
# vim: ft=zsh sw=2 ts=2 et
|
||||
|
|
|
|||
|
|
@ -87,3 +87,11 @@ function _cask() {
|
|||
}
|
||||
|
||||
_cask "$@"
|
||||
|
||||
# Local Variables:
|
||||
# mode: Shell-Script
|
||||
# sh-indentation: 2
|
||||
# indent-tabs-mode: nil
|
||||
# sh-basic-offset: 2
|
||||
# End:
|
||||
# vim: ft=zsh sw=2 ts=2 et
|
||||
|
|
|
|||
|
|
@ -248,7 +248,7 @@ __ccache_config_keys() {
|
|||
|
||||
if compset -P '--set-config=*='; then
|
||||
case $IPREFIX in
|
||||
( *=absolute_paths_in_stderr= | *=compression= | *=debug= | *=depend_mode= | *=direct_mode= | *=disable= | *=file_clone= | *=hard_link= | *=hash_dir= | *=inode_cache= | *=keep_comments_cpp= | *=read_only= | *=read_only_direct= | *=recache= | *=run_second_cpp= | *=stats= | *=unify= )
|
||||
( *=absolute_paths_in_stderr= | *=compression= | *=debug= | *=depend_mode= | *=direct_mode= | *=disable= | *=file_clone= | *=hard_link= | *=hash_dir= | *=inode_cache= | *=keep_comments_cpp= | *=read_only= | *=read_only_direct= | *=recache= | *=run_second_cpp= | *=stats= | *=unify= )
|
||||
local -a booleans=('true' 'false')
|
||||
_describe -t booleans 'boolean' booleans
|
||||
;;
|
||||
|
|
|
|||
8
src/_cf
8
src/_cf
|
|
@ -77,7 +77,7 @@ __cf_marketplace_services() {
|
|||
declare -a cont_cmd
|
||||
cont_cmd=($(CF_COLOR=false CF_TRACE=false cf marketplace | awk 'NR>4{print $1}'))
|
||||
if [[ "X$cont_cmd" != 'X' ]]; then
|
||||
_describe 'SERVICE' cont_cmd
|
||||
_describe 'SERVICE' cont_cmd
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
@ -86,7 +86,7 @@ __cf_services() {
|
|||
declare -a cont_cmd
|
||||
cont_cmd=($(CF_COLOR=false CF_TRACE=false cf services | awk 'NR>4{print $1}'))
|
||||
if [[ "X$cont_cmd" != 'X' ]]; then
|
||||
_describe 'SERVICE' cont_cmd
|
||||
_describe 'SERVICE' cont_cmd
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
@ -95,7 +95,7 @@ __cf_domains() {
|
|||
declare -a cont_cmd
|
||||
cont_cmd=($(CF_COLOR=false CF_TRACE=false cf domains | grep -v shared | awk 'NR>2{print $1}'))
|
||||
if [[ "X$cont_cmd" != 'X' ]]; then
|
||||
_describe 'DOMAIN' cont_cmd
|
||||
_describe 'DOMAIN' cont_cmd
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
@ -122,7 +122,7 @@ __cf_buildpacks() {
|
|||
declare -a cont_cmd
|
||||
cont_cmd=($(CF_COLOR=false CF_TRACE=false cf buildpacks | awk 'NR>3{print $1}'))
|
||||
if [[ "X$cont_cmd" != 'X' ]]; then
|
||||
_describe 'BUILDPACK' cont_cmd
|
||||
_describe 'BUILDPACK' cont_cmd
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -108,8 +108,8 @@ _chromium_proxyurls () {
|
|||
do
|
||||
while _next_label prefixes expl 'URL prefix' -S '' "$@"
|
||||
do
|
||||
compset -S '[^:/]*' && compstate[to_end]=''
|
||||
compadd "$expl[@]" http:// socks:// socks4:// socks5:// && ret=0
|
||||
compset -S '[^:/]*' && compstate[to_end]=''
|
||||
compadd "$expl[@]" http:// socks:// socks4:// socks5:// && ret=0
|
||||
done
|
||||
(( ret )) || return 0
|
||||
done
|
||||
|
|
@ -123,27 +123,27 @@ _chromium_proxyurls () {
|
|||
return
|
||||
fi ;;
|
||||
(file) [[ -prefix //(127.0.0.1|localhost)/ ]] && compset -P '//(127.0.0.1|localhost)'
|
||||
[[ -prefix /// ]] && compset -P //
|
||||
if ! compset -P //
|
||||
then
|
||||
_tags -C file files
|
||||
while _tags
|
||||
do
|
||||
while _next_label files expl 'local file'
|
||||
do
|
||||
if [[ -prefix / ]]
|
||||
then
|
||||
_path_files "$expl[@]" -S '' "${glob[@]}" && ret=0
|
||||
_path_files "$expl[@]" -S/ -r '/' -/ && ret=0
|
||||
elif [[ -z "$PREFIX" ]]
|
||||
then
|
||||
compadd -S '/' -r '/' "$expl[@]" "$@" - "${PWD%/}" && ret=0
|
||||
fi
|
||||
done
|
||||
(( ret )) || return 0
|
||||
done
|
||||
return 1
|
||||
fi ;;
|
||||
[[ -prefix /// ]] && compset -P //
|
||||
if ! compset -P //
|
||||
then
|
||||
_tags -C file files
|
||||
while _tags
|
||||
do
|
||||
while _next_label files expl 'local file'
|
||||
do
|
||||
if [[ -prefix / ]]
|
||||
then
|
||||
_path_files "$expl[@]" -S '' "${glob[@]}" && ret=0
|
||||
_path_files "$expl[@]" -S/ -r '/' -/ && ret=0
|
||||
elif [[ -z "$PREFIX" ]]
|
||||
then
|
||||
compadd -S '/' -r '/' "$expl[@]" "$@" - "${PWD%/}" && ret=0
|
||||
fi
|
||||
done
|
||||
(( ret )) || return 0
|
||||
done
|
||||
return 1
|
||||
fi ;;
|
||||
esac
|
||||
if ! compset -P '(#b)([^:/]#)([:/])'
|
||||
then
|
||||
|
|
@ -153,10 +153,10 @@ _chromium_proxyurls () {
|
|||
do
|
||||
while _next_label hosts expl host
|
||||
do
|
||||
compset -S '[:/]*' || suf="/"
|
||||
(( $#uhosts )) || _hosts -S "$suf" -r '/:' "$expl[@]" && ret=0
|
||||
[[ "$scheme" = http ]] && uhosts=($uhosts $localhttp_servername)
|
||||
compadd -S "$suf" -r '/:' "$expl[@]" -a uhosts && ret=0
|
||||
compset -S '[:/]*' || suf="/"
|
||||
(( $#uhosts )) || _hosts -S "$suf" -r '/:' "$expl[@]" && ret=0
|
||||
[[ "$scheme" = http ]] && uhosts=($uhosts $localhttp_servername)
|
||||
compadd -S "$suf" -r '/:' "$expl[@]" -a uhosts && ret=0
|
||||
done
|
||||
(( ret )) || return 0
|
||||
done
|
||||
|
|
@ -171,28 +171,28 @@ _chromium_proxyurls () {
|
|||
then
|
||||
if ! compset -P '(#b)([^/]#)/'
|
||||
then
|
||||
_users -S/ "$@"
|
||||
return
|
||||
_users -S/ "$@"
|
||||
return
|
||||
fi
|
||||
user="$match[1]"
|
||||
while _tags
|
||||
do
|
||||
while _next_label files expl 'local file'
|
||||
do
|
||||
_path_files "$expl[@]" "$@" -W ~$user/$localhttp_userdir "${glob[@]}" && ret=0
|
||||
_path_files -S/ -r '/' "$expl[@]" -W ~$user/$localhttp_userdir-/ && ret=0
|
||||
done
|
||||
(( ret )) || return 0
|
||||
while _next_label files expl 'local file'
|
||||
do
|
||||
_path_files "$expl[@]" "$@" -W ~$user/$localhttp_userdir "${glob[@]}" && ret=0
|
||||
_path_files -S/ -r '/' "$expl[@]" -W ~$user/$localhttp_userdir-/ && ret=0
|
||||
done
|
||||
(( ret )) || return 0
|
||||
done
|
||||
else
|
||||
while _tags
|
||||
do
|
||||
while _next_label files expl 'local file'
|
||||
do
|
||||
_path_files "$expl[@]" "$@" -W $localhttp_documentroot "${glob[@]}" && ret=0
|
||||
_path_files -S/ -r '/' "$expl[@]" -W $localhttp_documentroot -/ && ret=0
|
||||
done
|
||||
(( ret )) || return 0
|
||||
while _next_label files expl 'local file'
|
||||
do
|
||||
_path_files "$expl[@]" "$@" -W $localhttp_documentroot "${glob[@]}" && ret=0
|
||||
_path_files -S/ -r '/' "$expl[@]" -W $localhttp_documentroot -/ && ret=0
|
||||
done
|
||||
(( ret )) || return 0
|
||||
done
|
||||
fi
|
||||
else
|
||||
|
|
@ -200,8 +200,8 @@ _chromium_proxyurls () {
|
|||
do
|
||||
(( $#urls )) && while _next_label files expl 'local file'
|
||||
do
|
||||
_path_files "$expl[@]" "$@" -W $urls/$scheme/$host "${glob[@]}" && ret=0
|
||||
_path_files -S/ -r '/' "$expl[@]" -W $urls/$scheme/$host -/ && ret=0
|
||||
_path_files "$expl[@]" "$@" -W $urls/$scheme/$host "${glob[@]}" && ret=0
|
||||
_path_files -S/ -r '/' "$expl[@]" -W $urls/$scheme/$host -/ && ret=0
|
||||
done
|
||||
[[ $scheme = (scp|sftp) ]] && _requested remote-files && _remote_files -h $host -- ssh && ret=0
|
||||
(( ret )) || return 0
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ local -a cmake_build_options=(
|
|||
'-L-[List cache variables]::_values "options" "[non-advanced cache variables]" "A[advanced cache variables]" "H[non-advanced cached variables with help]" "AH[advanced cache variables with help]"'
|
||||
'--fresh[Configure a fresh build tree, removing any existing cache file]'
|
||||
|
||||
'--build[Build a CMake-generated project binary tree]:project directory:_path_files -/'
|
||||
'--build[Build a CMake-generated project binary tree]::project directory:_path_files -/'
|
||||
'--install[Install a CMake-generated project binary tree]:project directory:_path_files -/'
|
||||
'--open[Open generated project in the associated application]:project directory:_path_files -/'
|
||||
|
||||
|
|
|
|||
|
|
@ -151,9 +151,9 @@ _conan_cache() {
|
|||
local ret=1
|
||||
|
||||
_arguments -C \
|
||||
'(- *)'{-h,--help}'[show help message and exit]' \
|
||||
'1: :(clean path)' \
|
||||
'*:: :->args'
|
||||
'(- *)'{-h,--help}'[show help message and exit]' \
|
||||
'1: :(clean path)' \
|
||||
'*:: :->args'
|
||||
|
||||
case $state in
|
||||
(args)
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ _arguments \
|
|||
'--waitip=[Wait for an address to assigned before forking to the background]: :(4 6)' \
|
||||
\*{-x,--exit}'[This will signal an existing dhcpcd process running on the interface to exit]: :_net_interfaces' \
|
||||
'(-y --reboot)'{-y,--reboot}'[Allow reboot seconds before moving to the discover phase if we have an old lease to use]:seconds' \
|
||||
'1:network interface:_net_interfaces'
|
||||
'1:network interface:_net_interfaces'
|
||||
|
||||
# Local Variables:
|
||||
# mode: Shell-Script
|
||||
|
|
|
|||
|
|
@ -727,8 +727,8 @@ _flutter_custom_devices() {
|
|||
|
||||
_arguments -C \
|
||||
'(- *)'{-h,--help}'[Print this usage information]' \
|
||||
'1: :_flutter_custom_devices_subcommands' \
|
||||
'*:: :->args' \
|
||||
'1: :_flutter_custom_devices_subcommands' \
|
||||
'*:: :->args' \
|
||||
&& ret=0
|
||||
|
||||
case $state in
|
||||
|
|
|
|||
614
src/_git-flow
614
src/_git-flow
|
|
@ -40,397 +40,367 @@
|
|||
#
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
_git-flow () {
|
||||
local curcontext="$curcontext" state line
|
||||
typeset -A opt_args
|
||||
|
||||
_git-flow ()
|
||||
{
|
||||
local curcontext="$curcontext" state line
|
||||
typeset -A opt_args
|
||||
_arguments -C \
|
||||
':command:->command' \
|
||||
'*::options:->options'
|
||||
|
||||
_arguments -C \
|
||||
':command:->command' \
|
||||
'*::options:->options'
|
||||
case $state in
|
||||
(command)
|
||||
local -a subcommands
|
||||
subcommands=(
|
||||
'init:Initialize a new git repo with support for the branching model.'
|
||||
'feature:Manage your feature branches.'
|
||||
'release:Manage your release branches.'
|
||||
'hotfix:Manage your hotfix branches.'
|
||||
'support:Manage your support branches.'
|
||||
'version:Shows version information.'
|
||||
)
|
||||
_describe -t commands 'git flow' subcommands
|
||||
;;
|
||||
|
||||
case $state in
|
||||
(command)
|
||||
(options)
|
||||
case $line[1] in
|
||||
(init)
|
||||
_arguments \
|
||||
-f'[Force setting of gitflow branches, even if already configured]' \
|
||||
-d'[Use default branch naming conventions and prefixes]'
|
||||
;;
|
||||
(version)
|
||||
;;
|
||||
(hotfix)
|
||||
__git-flow-hotfix
|
||||
;;
|
||||
(release)
|
||||
__git-flow-release
|
||||
;;
|
||||
(feature)
|
||||
__git-flow-feature
|
||||
;;
|
||||
(support)
|
||||
__git-flow-support
|
||||
;;
|
||||
|
||||
local -a subcommands
|
||||
subcommands=(
|
||||
'init:Initialize a new git repo with support for the branching model.'
|
||||
'feature:Manage your feature branches.'
|
||||
'release:Manage your release branches.'
|
||||
'hotfix:Manage your hotfix branches.'
|
||||
'support:Manage your support branches.'
|
||||
'version:Shows version information.'
|
||||
)
|
||||
_describe -t commands 'git flow' subcommands
|
||||
;;
|
||||
|
||||
(options)
|
||||
case $line[1] in
|
||||
|
||||
(init)
|
||||
_arguments \
|
||||
-f'[Force setting of gitflow branches, even if already configured]' \
|
||||
-d'[Use default branch naming conventions and prefixes]'
|
||||
;;
|
||||
|
||||
(version)
|
||||
;;
|
||||
|
||||
(hotfix)
|
||||
__git-flow-hotfix
|
||||
;;
|
||||
|
||||
(release)
|
||||
__git-flow-release
|
||||
;;
|
||||
|
||||
(feature)
|
||||
__git-flow-feature
|
||||
;;
|
||||
|
||||
(support)
|
||||
__git-flow-support
|
||||
;;
|
||||
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
__git-flow-release ()
|
||||
{
|
||||
local curcontext="$curcontext" state line
|
||||
typeset -A opt_args
|
||||
__git-flow-release () {
|
||||
local curcontext="$curcontext" state line
|
||||
typeset -A opt_args
|
||||
|
||||
_arguments -C \
|
||||
':command:->command' \
|
||||
'*::options:->options'
|
||||
_arguments -C \
|
||||
':command:->command' \
|
||||
'*::options:->options'
|
||||
|
||||
case $state in
|
||||
(command)
|
||||
case $state in
|
||||
(command)
|
||||
local -a subcommands
|
||||
subcommands=(
|
||||
'start:Start a new release branch.'
|
||||
'finish:Finish a release branch.'
|
||||
'list:List all your release branches. (Alias to `git flow release`)'
|
||||
'publish:Publish this release branch to origin.`)'
|
||||
'track:Track a release branch from origin.`)'
|
||||
)
|
||||
_describe -t commands 'git flow release' subcommands
|
||||
_arguments \
|
||||
-v'[Verbose (more) output]'
|
||||
;;
|
||||
|
||||
local -a subcommands
|
||||
subcommands=(
|
||||
'start:Start a new release branch.'
|
||||
'finish:Finish a release branch.'
|
||||
'list:List all your release branches. (Alias to `git flow release`)'
|
||||
'publish:Publish this release branch to origin.`)'
|
||||
'track:Track a release branch from origin.`)'
|
||||
)
|
||||
_describe -t commands 'git flow release' subcommands
|
||||
_arguments \
|
||||
-v'[Verbose (more) output]'
|
||||
;;
|
||||
|
||||
(options)
|
||||
case $line[1] in
|
||||
|
||||
(start)
|
||||
_arguments \
|
||||
-F'[Fetch from origin before performing finish]'\
|
||||
':version:__git_flow_version_list'
|
||||
;;
|
||||
|
||||
(finish)
|
||||
_arguments \
|
||||
-F'[Fetch from origin before performing finish]' \
|
||||
-s'[Sign the release tag cryptographically]'\
|
||||
-u'[Use the given GPG-key for the digital signature (implies -s)]'\
|
||||
-m'[Use the given tag message]'\
|
||||
-n'[Don'\''t tag this release]'\
|
||||
-p'[Push to $ORIGIN after performing finish]'\
|
||||
-k'[Keep branch after performing finish]'\
|
||||
':version:__git_flow_version_list'
|
||||
;;
|
||||
|
||||
(publish)
|
||||
_arguments \
|
||||
':version:__git_flow_version_list'
|
||||
;;
|
||||
|
||||
(track)
|
||||
_arguments \
|
||||
':version:__git_flow_version_list'
|
||||
;;
|
||||
|
||||
|
||||
|
||||
*)
|
||||
_arguments \
|
||||
-v'[Verbose (more) output]'
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
(options)
|
||||
case $line[1] in
|
||||
(start)
|
||||
_arguments \
|
||||
-F'[Fetch from origin before performing finish]'\
|
||||
':version:__git_flow_version_list'
|
||||
;;
|
||||
(finish)
|
||||
_arguments \
|
||||
-F'[Fetch from origin before performing finish]' \
|
||||
-s'[Sign the release tag cryptographically]'\
|
||||
-u'[Use the given GPG-key for the digital signature (implies -s)]'\
|
||||
-m'[Use the given tag message]'\
|
||||
-n'[Don'\''t tag this release]'\
|
||||
-p'[Push to $ORIGIN after performing finish]'\
|
||||
-k'[Keep branch after performing finish]'\
|
||||
':version:__git_flow_version_list'
|
||||
;;
|
||||
(publish)
|
||||
_arguments \
|
||||
':version:__git_flow_version_list'
|
||||
;;
|
||||
(track)
|
||||
_arguments \
|
||||
':version:__git_flow_version_list'
|
||||
;;
|
||||
*)
|
||||
_arguments \
|
||||
-v'[Verbose (more) output]'
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
__git-flow-hotfix ()
|
||||
{
|
||||
local curcontext="$curcontext" state line
|
||||
typeset -A opt_args
|
||||
__git-flow-hotfix () {
|
||||
local curcontext="$curcontext" state line
|
||||
typeset -A opt_args
|
||||
|
||||
_arguments -C \
|
||||
':command:->command' \
|
||||
'*::options:->options'
|
||||
_arguments -C \
|
||||
':command:->command' \
|
||||
'*::options:->options'
|
||||
|
||||
case $state in
|
||||
(command)
|
||||
case $state in
|
||||
(command)
|
||||
local -a subcommands
|
||||
subcommands=(
|
||||
'start:Start a new hotfix branch.'
|
||||
'finish:Finish a hotfix branch.'
|
||||
'list:List all your hotfix branches. (Alias to `git flow hotfix`)'
|
||||
'publish:Publish this hotfix branch to origin`)'
|
||||
)
|
||||
_describe -t commands 'git flow hotfix' subcommands
|
||||
_arguments \
|
||||
-v'[Verbose (more) output]'
|
||||
;;
|
||||
|
||||
local -a subcommands
|
||||
subcommands=(
|
||||
'start:Start a new hotfix branch.'
|
||||
'finish:Finish a hotfix branch.'
|
||||
'list:List all your hotfix branches. (Alias to `git flow hotfix`)'
|
||||
'publish:Publish this hotfix branch to origin`)'
|
||||
)
|
||||
_describe -t commands 'git flow hotfix' subcommands
|
||||
_arguments \
|
||||
-v'[Verbose (more) output]'
|
||||
;;
|
||||
(options)
|
||||
case $line[1] in
|
||||
(start)
|
||||
_arguments \
|
||||
-F'[Fetch from origin before performing finish]'\
|
||||
':hotfix:__git_flow_version_list'\
|
||||
':branch-name:__git_branch_names'
|
||||
;;
|
||||
|
||||
(options)
|
||||
case $line[1] in
|
||||
(finish)
|
||||
_arguments \
|
||||
-F'[Fetch from origin before performing finish]' \
|
||||
-s'[Sign the release tag cryptographically]'\
|
||||
-u'[Use the given GPG-key for the digital signature (implies -s)]'\
|
||||
-m'[Use the given tag message]'\
|
||||
-p'[Push to $ORIGIN after performing finish]'\
|
||||
':hotfix:__git_flow_hotfix_list'
|
||||
;;
|
||||
|
||||
(start)
|
||||
_arguments \
|
||||
-F'[Fetch from origin before performing finish]'\
|
||||
':hotfix:__git_flow_version_list'\
|
||||
':branch-name:__git_branch_names'
|
||||
;;
|
||||
(publish)
|
||||
_arguments \
|
||||
':hotfix:__git_flow_hotfix_list'
|
||||
;;
|
||||
|
||||
(finish)
|
||||
_arguments \
|
||||
-F'[Fetch from origin before performing finish]' \
|
||||
-s'[Sign the release tag cryptographically]'\
|
||||
-u'[Use the given GPG-key for the digital signature (implies -s)]'\
|
||||
-m'[Use the given tag message]'\
|
||||
-p'[Push to $ORIGIN after performing finish]'\
|
||||
':hotfix:__git_flow_hotfix_list'
|
||||
;;
|
||||
|
||||
(publish)
|
||||
_arguments \
|
||||
':hotfix:__git_flow_hotfix_list'
|
||||
;;
|
||||
|
||||
*)
|
||||
_arguments \
|
||||
-v'[Verbose (more) output]'
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
*)
|
||||
_arguments \
|
||||
-v'[Verbose (more) output]'
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
__git-flow-feature ()
|
||||
{
|
||||
local curcontext="$curcontext" state line
|
||||
typeset -A opt_args
|
||||
__git-flow-feature () {
|
||||
local curcontext="$curcontext" state line
|
||||
typeset -A opt_args
|
||||
|
||||
_arguments -C \
|
||||
':command:->command' \
|
||||
'*::options:->options'
|
||||
_arguments -C \
|
||||
':command:->command' \
|
||||
'*::options:->options'
|
||||
|
||||
case $state in
|
||||
(command)
|
||||
|
||||
local -a subcommands
|
||||
subcommands=(
|
||||
'start:Start a new feature branch.'
|
||||
'finish:Finish a feature branch.'
|
||||
'list:List all your feature branches. (Alias to `git flow feature`)'
|
||||
'publish:Publish this feature branch to origin.'
|
||||
'track:Track a feature branch from origin.'
|
||||
'diff:Show a diff of changes since this feature branched off.'
|
||||
'rebase:Rebase a feature branch on top of develop.'
|
||||
case $state in
|
||||
(command)
|
||||
local -a subcommands
|
||||
subcommands=(
|
||||
'start:Start a new feature branch.'
|
||||
'finish:Finish a feature branch.'
|
||||
'list:List all your feature branches. (Alias to `git flow feature`)'
|
||||
'publish:Publish this feature branch to origin.'
|
||||
'track:Track a feature branch from origin.'
|
||||
'diff:Show a diff of changes since this feature branched off.'
|
||||
'rebase:Rebase a feature branch on top of develop.'
|
||||
'checkout:Check out (switch to) the given feature branch.'
|
||||
'pull:Pull a feature branch from a remote peer.'
|
||||
)
|
||||
_describe -t commands 'git flow feature' subcommands
|
||||
_arguments \
|
||||
-v'[Verbose (more) output]'
|
||||
;;
|
||||
'pull:Pull a feature branch from a remote peer.'
|
||||
)
|
||||
_describe -t commands 'git flow feature' subcommands
|
||||
_arguments \
|
||||
-v'[Verbose (more) output]'
|
||||
;;
|
||||
|
||||
(options)
|
||||
case $line[1] in
|
||||
(options)
|
||||
case $line[1] in
|
||||
(start)
|
||||
_arguments \
|
||||
-F'[Fetch from origin before performing finish]'\
|
||||
':feature:__git_flow_feature_list'\
|
||||
':branch-name:__git_branch_names'
|
||||
;;
|
||||
|
||||
(start)
|
||||
_arguments \
|
||||
-F'[Fetch from origin before performing finish]'\
|
||||
':feature:__git_flow_feature_list'\
|
||||
':branch-name:__git_branch_names'
|
||||
;;
|
||||
(finish)
|
||||
_arguments \
|
||||
-F'[Fetch from origin before performing finish]' \
|
||||
-r'[Finish branch by rebasing first]'\
|
||||
-k'[Keep branch after performing finish]'\
|
||||
-D'[Force delete feature branch after finish]'\
|
||||
':feature:__git_flow_feature_list'
|
||||
;;
|
||||
|
||||
(finish)
|
||||
_arguments \
|
||||
-F'[Fetch from origin before performing finish]' \
|
||||
-r'[Finish branch by rebasing first]'\
|
||||
-k'[Keep branch after performing finish]'\
|
||||
-D'[Force delete feature branch after finish]'\
|
||||
':feature:__git_flow_feature_list'
|
||||
;;
|
||||
(publish)
|
||||
_arguments \
|
||||
':feature:__git_flow_feature_list'\
|
||||
;;
|
||||
|
||||
(publish)
|
||||
_arguments \
|
||||
':feature:__git_flow_feature_list'\
|
||||
;;
|
||||
(track)
|
||||
_arguments \
|
||||
':feature:__git_flow_feature_list'\
|
||||
;;
|
||||
|
||||
(track)
|
||||
_arguments \
|
||||
':feature:__git_flow_feature_list'\
|
||||
;;
|
||||
(diff)
|
||||
_arguments \
|
||||
':branch:__git_branch_names'\
|
||||
;;
|
||||
|
||||
(diff)
|
||||
_arguments \
|
||||
':branch:__git_branch_names'\
|
||||
;;
|
||||
(rebase)
|
||||
_arguments \
|
||||
-i'[Do an interactive rebase]' \
|
||||
':branch:__git_branch_names'
|
||||
;;
|
||||
|
||||
(rebase)
|
||||
_arguments \
|
||||
-i'[Do an interactive rebase]' \
|
||||
':branch:__git_branch_names'
|
||||
;;
|
||||
(checkout)
|
||||
_arguments \
|
||||
':branch:__git_flow_feature_list'\
|
||||
;;
|
||||
|
||||
(checkout)
|
||||
_arguments \
|
||||
':branch:__git_flow_feature_list'\
|
||||
;;
|
||||
(pull)
|
||||
_arguments \
|
||||
':remote:__git_remotes'\
|
||||
':branch:__git_branch_names'
|
||||
;;
|
||||
|
||||
(pull)
|
||||
_arguments \
|
||||
':remote:__git_remotes'\
|
||||
':branch:__git_branch_names'
|
||||
;;
|
||||
|
||||
*)
|
||||
_arguments \
|
||||
-v'[Verbose (more) output]'
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
*)
|
||||
_arguments \
|
||||
-v'[Verbose (more) output]'
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
__git-flow-support ()
|
||||
{
|
||||
local curcontext="$curcontext" state line
|
||||
typeset -A opt_args
|
||||
__git-flow-support () {
|
||||
local curcontext="$curcontext" state line
|
||||
typeset -A opt_args
|
||||
|
||||
_arguments -C \
|
||||
':command:->command' \
|
||||
'*::options:->options'
|
||||
_arguments -C \
|
||||
':command:->command' \
|
||||
'*::options:->options'
|
||||
|
||||
case $state in
|
||||
(command)
|
||||
case $state in
|
||||
(command)
|
||||
|
||||
local -a subcommands
|
||||
subcommands=(
|
||||
'start:Start a new support branch.'
|
||||
'list:List all your support branches. (Alias to `git flow support`)'
|
||||
)
|
||||
_describe -t commands 'git flow support' subcommands
|
||||
_arguments \
|
||||
-v'[Verbose (more) output]'
|
||||
;;
|
||||
local -a subcommands
|
||||
subcommands=(
|
||||
'start:Start a new support branch.'
|
||||
'list:List all your support branches. (Alias to `git flow support`)'
|
||||
)
|
||||
_describe -t commands 'git flow support' subcommands
|
||||
_arguments \
|
||||
-v'[Verbose (more) output]'
|
||||
;;
|
||||
|
||||
(options)
|
||||
case $line[1] in
|
||||
(options)
|
||||
case $line[1] in
|
||||
|
||||
(start)
|
||||
_arguments \
|
||||
-F'[Fetch from origin before performing finish]'\
|
||||
':feature:__git_flow_support_list'\
|
||||
':branch-name:__git_branch_names'
|
||||
;;
|
||||
(start)
|
||||
_arguments \
|
||||
-F'[Fetch from origin before performing finish]'\
|
||||
':feature:__git_flow_support_list'\
|
||||
':branch-name:__git_branch_names'
|
||||
;;
|
||||
|
||||
*)
|
||||
_arguments \
|
||||
-v'[Verbose (more) output]'
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
*)
|
||||
_arguments \
|
||||
-v'[Verbose (more) output]'
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
__git_flow_version_list ()
|
||||
{
|
||||
local expl
|
||||
declare -a versions
|
||||
__git_flow_version_list () {
|
||||
local expl
|
||||
declare -a versions
|
||||
|
||||
versions=(${${(f)"$(_call_program versions git flow release list 2> /dev/null | tr -d ' |*')"}})
|
||||
__git_command_successful || return
|
||||
versions=(${${(f)"$(_call_program versions git flow release list 2> /dev/null | tr -d ' |*')"}})
|
||||
__git_command_successful || return
|
||||
|
||||
_wanted versions expl 'version' compadd $versions
|
||||
_wanted versions expl 'version' compadd $versions
|
||||
}
|
||||
|
||||
__git_flow_feature_list ()
|
||||
{
|
||||
local expl
|
||||
declare -a features
|
||||
__git_flow_feature_list () {
|
||||
local expl
|
||||
declare -a features
|
||||
|
||||
features=(${${(f)"$(_call_program features git flow feature list 2> /dev/null | tr -d ' |*')"}})
|
||||
__git_command_successful || return
|
||||
features=(${${(f)"$(_call_program features git flow feature list 2> /dev/null | tr -d ' |*')"}})
|
||||
__git_command_successful || return
|
||||
|
||||
_wanted features expl 'feature' compadd $features
|
||||
_wanted features expl 'feature' compadd $features
|
||||
}
|
||||
|
||||
__git_remotes () {
|
||||
local expl gitdir remotes
|
||||
local expl gitdir remotes
|
||||
|
||||
gitdir=$(_call_program gitdir git rev-parse --git-dir 2>/dev/null)
|
||||
__git_command_successful || return
|
||||
gitdir=$(_call_program gitdir git rev-parse --git-dir 2>/dev/null)
|
||||
__git_command_successful || return
|
||||
|
||||
remotes=(${${(f)"$(_call_program remotes git config --get-regexp '"^remote\..*\.url$"')"}//#(#b)remote.(*).url */$match[1]})
|
||||
__git_command_successful || return
|
||||
remotes=(${${(f)"$(_call_program remotes git config --get-regexp '"^remote\..*\.url$"')"}//#(#b)remote.(*).url */$match[1]})
|
||||
__git_command_successful || return
|
||||
|
||||
# TODO: Should combine the two instead of either or.
|
||||
if (( $#remotes > 0 )); then
|
||||
_wanted remotes expl remote compadd $* - $remotes
|
||||
else
|
||||
_wanted remotes expl remote _files $* - -W "($gitdir/remotes)" -g "$gitdir/remotes/*"
|
||||
fi
|
||||
# TODO: Should combine the two instead of either or.
|
||||
if (( $#remotes > 0 )); then
|
||||
_wanted remotes expl remote compadd $* - $remotes
|
||||
else
|
||||
_wanted remotes expl remote _files $* - -W "($gitdir/remotes)" -g "$gitdir/remotes/*"
|
||||
fi
|
||||
}
|
||||
|
||||
__git_flow_hotfix_list ()
|
||||
{
|
||||
local expl
|
||||
declare -a hotfixes
|
||||
__git_flow_hotfix_list () {
|
||||
local expl
|
||||
declare -a hotfixes
|
||||
|
||||
hotfixes=(${${(f)"$(_call_program hotfixes git flow hotfix list 2> /dev/null | tr -d ' |*')"}})
|
||||
__git_command_successful || return
|
||||
hotfixes=(${${(f)"$(_call_program hotfixes git flow hotfix list 2> /dev/null | tr -d ' |*')"}})
|
||||
__git_command_successful || return
|
||||
|
||||
_wanted hotfixes expl 'hotfix' compadd $hotfixes
|
||||
_wanted hotfixes expl 'hotfix' compadd $hotfixes
|
||||
}
|
||||
|
||||
__git_flow_support_list ()
|
||||
{
|
||||
local expl
|
||||
declare -a support
|
||||
__git_flow_support_list () {
|
||||
local expl
|
||||
declare -a support
|
||||
|
||||
support=(${${(f)"$(_call_program support git flow support list 2> /dev/null | tr -d ' |*')"}})
|
||||
__git_command_successful || return
|
||||
support=(${${(f)"$(_call_program support git flow support list 2> /dev/null | tr -d ' |*')"}})
|
||||
__git_command_successful || return
|
||||
|
||||
_wanted hotfixes expl 'support' compadd $support
|
||||
_wanted hotfixes expl 'support' compadd $support
|
||||
}
|
||||
|
||||
|
||||
__git_branch_names () {
|
||||
local expl
|
||||
declare -a branch_names
|
||||
local expl
|
||||
declare -a branch_names
|
||||
|
||||
branch_names=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/heads 2>/dev/null)"}#refs/heads/})
|
||||
__git_command_successful || return
|
||||
branch_names=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/heads 2>/dev/null)"}#refs/heads/})
|
||||
__git_command_successful || return
|
||||
|
||||
_wanted branch-names expl branch-name compadd $* - $branch_names
|
||||
_wanted branch-names expl branch-name compadd $* - $branch_names
|
||||
}
|
||||
|
||||
__git_command_successful () {
|
||||
if (( ${#pipestatus:#0} > 0 )); then
|
||||
_message 'not a git repository'
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
if (( ${#pipestatus:#0} > 0 )); then
|
||||
_message 'not a git repository'
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
_git-flow "$@"
|
||||
|
|
|
|||
11
src/_hello
11
src/_hello
|
|
@ -13,7 +13,16 @@
|
|||
#
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
_arguments -s '(- *)'{-h,--help}'[display this help and exit]' \
|
||||
_arguments -s \
|
||||
'(- *)'{-h,--help}'[display this help and exit]' \
|
||||
'(- *)'{-v,--version}'[display version information and exit]' \
|
||||
{-t,--traditional}'[use traditional greeting]' \
|
||||
{-g,--greeting=}'[use TEXT as the greeting message]:TEXT'
|
||||
|
||||
# Local Variables:
|
||||
# mode: Shell-Script
|
||||
# sh-indentation: 2
|
||||
# indent-tabs-mode: nil
|
||||
# sh-basic-offset: 2
|
||||
# End:
|
||||
# vim: ft=zsh sw=2 ts=2 et
|
||||
|
|
|
|||
|
|
@ -284,3 +284,11 @@ while (( $#state )); do
|
|||
done
|
||||
|
||||
return ret
|
||||
|
||||
# Local Variables:
|
||||
# mode: Shell-Script
|
||||
# sh-indentation: 2
|
||||
# indent-tabs-mode: nil
|
||||
# sh-basic-offset: 2
|
||||
# End:
|
||||
# vim: ft=zsh sw=2 ts=2 et
|
||||
|
|
|
|||
|
|
@ -84,3 +84,11 @@ _kitchen_instances() {
|
|||
}
|
||||
|
||||
_kitchen "$@"
|
||||
|
||||
# Local Variables:
|
||||
# mode: Shell-Script
|
||||
# sh-indentation: 2
|
||||
# indent-tabs-mode: nil
|
||||
# sh-basic-offset: 2
|
||||
# End:
|
||||
# vim: ft=zsh sw=2 ts=2 et
|
||||
|
|
|
|||
|
|
@ -230,7 +230,7 @@ _language_codes() {
|
|||
|
||||
case $command in
|
||||
ISO-639-1)
|
||||
_language_codes_${${command//-/_}:l} "${@[1,-2]}" && ret=0
|
||||
_language_codes_${${command//-/_}:l} "${@[1,-2]}" && ret=0
|
||||
;;
|
||||
*)
|
||||
_message "unknown command: $command"
|
||||
|
|
|
|||
|
|
@ -154,3 +154,11 @@ case $state in
|
|||
esac
|
||||
|
||||
return ret
|
||||
|
||||
# Local Variables:
|
||||
# mode: Shell-Script
|
||||
# sh-indentation: 2
|
||||
# indent-tabs-mode: nil
|
||||
# sh-basic-offset: 2
|
||||
# End:
|
||||
# vim: ft=zsh sw=2 ts=2 et
|
||||
|
|
|
|||
346
src/_mix
346
src/_mix
|
|
@ -45,196 +45,198 @@
|
|||
|
||||
local -a _1st_arguments
|
||||
_1st_arguments=(
|
||||
'app.start:Starts all registered apps'
|
||||
'app.tree:Prints the application tree'
|
||||
'archive:Lists installed archives'
|
||||
'archive.build:Archives this project into a .ez file'
|
||||
'archive.install:Installs an archive locally'
|
||||
'archive.uninstall:Uninstalls archives'
|
||||
'clean:Deletes generated application files'
|
||||
'cmd:Executes the given command'
|
||||
'compile:Compiles source files'
|
||||
'deps:Lists dependencies and their status'
|
||||
"deps.clean:Deletes the given dependencies' files"
|
||||
'deps.compile:Compiles dependencies'
|
||||
'deps.get:Gets all out of date dependencies'
|
||||
'deps.tree:Prints the dependency tree'
|
||||
'deps.unlock:Unlocks the given dependencies'
|
||||
'deps.update:Updates the given dependencies'
|
||||
'do:Executes the tasks separated by comma'
|
||||
'ecto:Prints Ecto help information'
|
||||
'ecto.create:Creates the repository storage'
|
||||
'ecto.drop:Drops the repository storage'
|
||||
'ecto.dump:Dumps the repository database structure'
|
||||
'ecto.gen.migration:Generates a new migration for the repo'
|
||||
'ecto.gen.repo:Generates a new repository'
|
||||
'ecto.load:Loads previously dumped database structure'
|
||||
'ecto.migrate:Runs the repository migrations'
|
||||
'ecto.migrations:Displays the repository migration status'
|
||||
'ecto.rollback:Rolls back the repository migrations'
|
||||
'escript:Lists installed escripts'
|
||||
'escript.build:Builds an escript for the project'
|
||||
'escript.install:Installs an escript locally'
|
||||
'escript.uninstall:Uninstalls escripts'
|
||||
'gettext.extract:Extracts translations from source code'
|
||||
'gettext.merge:Merge template files into translation files'
|
||||
'help:Prints help information for tasks'
|
||||
'hex:Prints Hex help information'
|
||||
'hex.build:Builds a new package version locally'
|
||||
'hex.config:Reads, updates or deletes Hex config'
|
||||
'hex.docs:Fetch or open documentation of a package'
|
||||
'hex.info:Prints Hex information'
|
||||
'hex.key:Manages Hex API key'
|
||||
'hex.outdated:Shows outdated Hex deps for the current project'
|
||||
'hex.owner:Manages Hex package ownership'
|
||||
'hex.public_keys:Manages Hex public keys'
|
||||
'hex.publish:Publishes a new package version'
|
||||
'hex.retire:Retires a package version'
|
||||
'hex.search:Searches for package names'
|
||||
'hex.user:Registers or manages Hex user'
|
||||
'loadconfig:Loads and persists the given configuration'
|
||||
'local:Lists local tasks'
|
||||
'local.hex:Installs Hex locally'
|
||||
'local.phoenix:Updates Phoenix locally'
|
||||
'local.phx:Updates the Phoenix project generator locally'
|
||||
'local.public_keys:Manages public keys'
|
||||
'local.rebar:Installs Rebar locally'
|
||||
'new:Creates a new Elixir project'
|
||||
'phoenix.gen.html:Generates controller, model and views for an HTML based resource'
|
||||
'phoenix.server:Starts applications and their servers'
|
||||
'phx.digest:Digests and compresses static files'
|
||||
'phx.digest.clean:Removes old versions of static assets.'
|
||||
'phx.gen.auth:Generates a flexible, pre-built authentication system'
|
||||
'phx.gen.channel:Generates a Phoenix channel'
|
||||
'phx.gen.context:Generates a context with functions around an Ecto schema'
|
||||
'phx.gen.html:Generates controller, views, and context for an HTML resource'
|
||||
'phx.gen.live:Generates controller, context and helper for a LiveView resource'
|
||||
'phx.gen.json:Generates controller, views, and context for a JSON resource'
|
||||
'phx.gen.presence:Generates a Presence tracker'
|
||||
'phx.gen.schema:Generates an Ecto schema and migration file'
|
||||
'phx.gen.secret:Generates a secret'
|
||||
'phx.new:Creates a new Phoenix application'
|
||||
'phx.new.ecto:Creates a new Ecto project within an umbrella project'
|
||||
'phx.new.web:Creates a new Phoenix web project within an umbrella project'
|
||||
'phx.routes:Prints all routes'
|
||||
'phx.server:Starts applications and their servers'
|
||||
'profile.fprof:Profiles the given file or expression with fprof'
|
||||
'run:Runs the given file or expression'
|
||||
"test:Runs a project's tests"
|
||||
'xref:Performs cross reference checks'
|
||||
'--help:Describe available tasks'
|
||||
'--version:Prints the Elixir version information'
|
||||
'app.start:Starts all registered apps'
|
||||
'app.tree:Prints the application tree'
|
||||
'archive:Lists installed archives'
|
||||
'archive.build:Archives this project into a .ez file'
|
||||
'archive.install:Installs an archive locally'
|
||||
'archive.uninstall:Uninstalls archives'
|
||||
'clean:Deletes generated application files'
|
||||
'cmd:Executes the given command'
|
||||
'compile:Compiles source files'
|
||||
'deps:Lists dependencies and their status'
|
||||
"deps.clean:Deletes the given dependencies' files"
|
||||
'deps.compile:Compiles dependencies'
|
||||
'deps.get:Gets all out of date dependencies'
|
||||
'deps.tree:Prints the dependency tree'
|
||||
'deps.unlock:Unlocks the given dependencies'
|
||||
'deps.update:Updates the given dependencies'
|
||||
'do:Executes the tasks separated by comma'
|
||||
'ecto:Prints Ecto help information'
|
||||
'ecto.create:Creates the repository storage'
|
||||
'ecto.drop:Drops the repository storage'
|
||||
'ecto.dump:Dumps the repository database structure'
|
||||
'ecto.gen.migration:Generates a new migration for the repo'
|
||||
'ecto.gen.repo:Generates a new repository'
|
||||
'ecto.load:Loads previously dumped database structure'
|
||||
'ecto.migrate:Runs the repository migrations'
|
||||
'ecto.migrations:Displays the repository migration status'
|
||||
'ecto.rollback:Rolls back the repository migrations'
|
||||
'escript:Lists installed escripts'
|
||||
'escript.build:Builds an escript for the project'
|
||||
'escript.install:Installs an escript locally'
|
||||
'escript.uninstall:Uninstalls escripts'
|
||||
'gettext.extract:Extracts translations from source code'
|
||||
'gettext.merge:Merge template files into translation files'
|
||||
'help:Prints help information for tasks'
|
||||
'hex:Prints Hex help information'
|
||||
'hex.build:Builds a new package version locally'
|
||||
'hex.config:Reads, updates or deletes Hex config'
|
||||
'hex.docs:Fetch or open documentation of a package'
|
||||
'hex.info:Prints Hex information'
|
||||
'hex.key:Manages Hex API key'
|
||||
'hex.outdated:Shows outdated Hex deps for the current project'
|
||||
'hex.owner:Manages Hex package ownership'
|
||||
'hex.public_keys:Manages Hex public keys'
|
||||
'hex.publish:Publishes a new package version'
|
||||
'hex.retire:Retires a package version'
|
||||
'hex.search:Searches for package names'
|
||||
'hex.user:Registers or manages Hex user'
|
||||
'loadconfig:Loads and persists the given configuration'
|
||||
'local:Lists local tasks'
|
||||
'local.hex:Installs Hex locally'
|
||||
'local.phoenix:Updates Phoenix locally'
|
||||
'local.phx:Updates the Phoenix project generator locally'
|
||||
'local.public_keys:Manages public keys'
|
||||
'local.rebar:Installs Rebar locally'
|
||||
'new:Creates a new Elixir project'
|
||||
'phoenix.gen.html:Generates controller, model and views for an HTML based resource'
|
||||
'phoenix.server:Starts applications and their servers'
|
||||
'phx.digest:Digests and compresses static files'
|
||||
'phx.digest.clean:Removes old versions of static assets.'
|
||||
'phx.gen.auth:Generates a flexible, pre-built authentication system'
|
||||
'phx.gen.channel:Generates a Phoenix channel'
|
||||
'phx.gen.context:Generates a context with functions around an Ecto schema'
|
||||
'phx.gen.html:Generates controller, views, and context for an HTML resource'
|
||||
'phx.gen.live:Generates controller, context and helper for a LiveView resource'
|
||||
'phx.gen.json:Generates controller, views, and context for a JSON resource'
|
||||
'phx.gen.presence:Generates a Presence tracker'
|
||||
'phx.gen.schema:Generates an Ecto schema and migration file'
|
||||
'phx.gen.secret:Generates a secret'
|
||||
'phx.new:Creates a new Phoenix application'
|
||||
'phx.new.ecto:Creates a new Ecto project within an umbrella project'
|
||||
'phx.new.web:Creates a new Phoenix web project within an umbrella project'
|
||||
'phx.routes:Prints all routes'
|
||||
'phx.server:Starts applications and their servers'
|
||||
'profile.fprof:Profiles the given file or expression with fprof'
|
||||
'run:Runs the given file or expression'
|
||||
"test:Runs a project's tests"
|
||||
'xref:Performs cross reference checks'
|
||||
'--help:Describe available tasks'
|
||||
'--version:Prints the Elixir version information'
|
||||
)
|
||||
|
||||
__task_list ()
|
||||
{
|
||||
local expl
|
||||
declare -a tasks
|
||||
__task_list () {
|
||||
local expl
|
||||
declare -a tasks
|
||||
|
||||
tasks=(
|
||||
'app.start'
|
||||
'app.tree'
|
||||
'archive'
|
||||
'archive.build'
|
||||
'archive.install'
|
||||
'archive.uninstall'
|
||||
'clean'
|
||||
'cmd'
|
||||
'compile'
|
||||
'deps'
|
||||
'deps.clean'
|
||||
'deps.compile'
|
||||
'deps.get'
|
||||
'deps.tree'
|
||||
'deps.unlock'
|
||||
'deps.update'
|
||||
'do'
|
||||
'ecto'
|
||||
'ecto.create'
|
||||
'ecto.drop'
|
||||
'ecto.dump'
|
||||
'ecto.gen.migration'
|
||||
'ecto.gen.repo'
|
||||
'ecto.load'
|
||||
'ecto.migrate'
|
||||
'ecto.migrations'
|
||||
'ecto.rollback'
|
||||
'escript'
|
||||
'escript.build'
|
||||
'escript.install'
|
||||
'escript.uninstall'
|
||||
'gettext.extract'
|
||||
'gettext.merge'
|
||||
'format'
|
||||
'help'
|
||||
'hex'
|
||||
'hex.build'
|
||||
'hex.config'
|
||||
'hex.docs'
|
||||
'hex.info'
|
||||
'hex.key'
|
||||
'hex.outdated'
|
||||
'hex.owner'
|
||||
'hex.public_keys'
|
||||
'hex.publish'
|
||||
'hex.retire'
|
||||
'hex.search'
|
||||
'hex.user'
|
||||
'loadconfig'
|
||||
'local'
|
||||
'local.hex'
|
||||
'local.public_keys'
|
||||
'local.rebar'
|
||||
'new'
|
||||
'phoenix.gen.html'
|
||||
'phoenix.server'
|
||||
'phx.digest'
|
||||
'phx.digest.clean'
|
||||
'phx.gen.auth'
|
||||
'phx.gen.channel'
|
||||
'phx.gen.context'
|
||||
'phx.gen.html'
|
||||
'phx.gen.live'
|
||||
'phx.gen.json'
|
||||
'phx.gen.presence'
|
||||
'phx.gen.schema'
|
||||
'phx.gen.secret'
|
||||
'phx.routes'
|
||||
'phx.server'
|
||||
'profile.fprof'
|
||||
'run'
|
||||
'test'
|
||||
'xref'
|
||||
)
|
||||
tasks=(
|
||||
'app.start'
|
||||
'app.tree'
|
||||
'archive'
|
||||
'archive.build'
|
||||
'archive.install'
|
||||
'archive.uninstall'
|
||||
'clean'
|
||||
'cmd'
|
||||
'compile'
|
||||
'deps'
|
||||
'deps.clean'
|
||||
'deps.compile'
|
||||
'deps.get'
|
||||
'deps.tree'
|
||||
'deps.unlock'
|
||||
'deps.update'
|
||||
'do'
|
||||
'ecto'
|
||||
'ecto.create'
|
||||
'ecto.drop'
|
||||
'ecto.dump'
|
||||
'ecto.gen.migration'
|
||||
'ecto.gen.repo'
|
||||
'ecto.load'
|
||||
'ecto.migrate'
|
||||
'ecto.migrations'
|
||||
'ecto.rollback'
|
||||
'escript'
|
||||
'escript.build'
|
||||
'escript.install'
|
||||
'escript.uninstall'
|
||||
'gettext.extract'
|
||||
'gettext.merge'
|
||||
'format'
|
||||
'help'
|
||||
'hex'
|
||||
'hex.build'
|
||||
'hex.config'
|
||||
'hex.docs'
|
||||
'hex.info'
|
||||
'hex.key'
|
||||
'hex.outdated'
|
||||
'hex.owner'
|
||||
'hex.public_keys'
|
||||
'hex.publish'
|
||||
'hex.retire'
|
||||
'hex.search'
|
||||
'hex.user'
|
||||
'loadconfig'
|
||||
'local'
|
||||
'local.hex'
|
||||
'local.public_keys'
|
||||
'local.rebar'
|
||||
'new'
|
||||
'phoenix.gen.html'
|
||||
'phoenix.server'
|
||||
'phx.digest'
|
||||
'phx.digest.clean'
|
||||
'phx.gen.auth'
|
||||
'phx.gen.channel'
|
||||
'phx.gen.context'
|
||||
'phx.gen.html'
|
||||
'phx.gen.live'
|
||||
'phx.gen.json'
|
||||
'phx.gen.presence'
|
||||
'phx.gen.schema'
|
||||
'phx.gen.secret'
|
||||
'phx.routes'
|
||||
'phx.server'
|
||||
'profile.fprof'
|
||||
'run'
|
||||
'test'
|
||||
'xref'
|
||||
)
|
||||
|
||||
_wanted tasks expl 'help' compadd $tasks
|
||||
_wanted tasks expl 'help' compadd $tasks
|
||||
}
|
||||
|
||||
local expl
|
||||
|
||||
local curcontext="$curcontext" state line
|
||||
typeset -A opt_args
|
||||
|
||||
_arguments -C \
|
||||
':command:->command' \
|
||||
'*::options:->options'
|
||||
':command:->command' \
|
||||
'*::options:->options'
|
||||
|
||||
case $state in
|
||||
(command)
|
||||
_describe -t commands "mix subcommand" _1st_arguments
|
||||
return
|
||||
;;
|
||||
|
||||
_describe -t commands "mix subcommand" _1st_arguments
|
||||
;;
|
||||
(options)
|
||||
case $line[1] in
|
||||
(help)
|
||||
_arguments ':feature:__task_list'
|
||||
return
|
||||
;;
|
||||
_arguments ':feature:__task_list'
|
||||
;;
|
||||
(test|format|run)
|
||||
_arguments ':PATH:_files'
|
||||
return
|
||||
;;
|
||||
_arguments ':PATH:_files'
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
|
||||
# Local Variables:
|
||||
# mode: Shell-Script
|
||||
# sh-indentation: 2
|
||||
# indent-tabs-mode: nil
|
||||
# sh-basic-offset: 2
|
||||
# End:
|
||||
# vim: ft=zsh sw=2 ts=2 et
|
||||
|
|
|
|||
|
|
@ -106,3 +106,11 @@ _describe 'command' instances
|
|||
# Reference:
|
||||
# https://zsh.sourceforge.net/Doc/Release/Completion-System.html
|
||||
# https://github.com/zsh-users/zsh-completions/blob/master/zsh-completions-howto.org
|
||||
|
||||
# Local Variables:
|
||||
# mode: Shell-Script
|
||||
# sh-indentation: 2
|
||||
# indent-tabs-mode: nil
|
||||
# sh-basic-offset: 2
|
||||
# End:
|
||||
# vim: ft=zsh sw=2 ts=2 et
|
||||
|
|
|
|||
10
src/_mvn
10
src/_mvn
|
|
@ -104,11 +104,11 @@ _mvn() {
|
|||
|
||||
if [[ $maven_version == 'maven4' ]]; then
|
||||
opts+=(
|
||||
"($excl_opts -canf --cache-artifact-not-found)"{-canf,--cache-artifact-not-found}'[defines caching behaviour for not found artifacts]: :(false true)'
|
||||
"($excl_opts -fos --fail-on-severity)"{-fos,--fail-on-severity}'[configure which severity of logging should cause the build to fail]: :(WARN ERROR)'
|
||||
"($excl_opts -itr --ignore-transitive-repositories)"{-itr,--ignore-transitive-repositories}'[if set, Maven will ignore remote repositories introduced by transitive dependencies]'
|
||||
"($excl_opts --non-interactive)"'--non-interactive[run in non-interactive mode. Alias for --batch-mode]'
|
||||
"($excl_opts -r --resume)"{-r,--resume}'[resume reactor from the last failed project, using the resume.properties file in the build directory]'
|
||||
"($excl_opts -canf --cache-artifact-not-found)"{-canf,--cache-artifact-not-found}'[defines caching behaviour for not found artifacts]: :(false true)'
|
||||
"($excl_opts -fos --fail-on-severity)"{-fos,--fail-on-severity}'[configure which severity of logging should cause the build to fail]: :(WARN ERROR)'
|
||||
"($excl_opts -itr --ignore-transitive-repositories)"{-itr,--ignore-transitive-repositories}'[if set, Maven will ignore remote repositories introduced by transitive dependencies]'
|
||||
"($excl_opts --non-interactive)"'--non-interactive[run in non-interactive mode. Alias for --batch-mode]'
|
||||
"($excl_opts -r --resume)"{-r,--resume}'[resume reactor from the last failed project, using the resume.properties file in the build directory]'
|
||||
)
|
||||
fi
|
||||
|
||||
|
|
|
|||
|
|
@ -144,3 +144,11 @@ local options=(
|
|||
)
|
||||
|
||||
_arguments $options "*::func_name:($func_names)"
|
||||
|
||||
# Local Variables:
|
||||
# mode: Shell-Script
|
||||
# sh-indentation: 2
|
||||
# indent-tabs-mode: nil
|
||||
# sh-basic-offset: 2
|
||||
# End:
|
||||
# vim: ft=zsh sw=2 ts=2 et
|
||||
|
|
|
|||
516
src/_nftables
516
src/_nftables
|
|
@ -12,278 +12,280 @@
|
|||
# * Markus Richter ( https://github.com/mqus , <mqus@disroot.org>)
|
||||
#
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
_nft(){
|
||||
local -a rules states prev args families options descriptors
|
||||
local state="start" line nextstate cmd_obj cmd_subcmd cmd_fam cmd_tab cmd_chain #curcontext="$curcontext"
|
||||
local -a rules states prev args families options descriptors
|
||||
local state="start" line nextstate cmd_obj cmd_subcmd cmd_fam cmd_tab cmd_chain #curcontext="$curcontext"
|
||||
|
||||
options=(
|
||||
'(-)'{-h,--help}'[show help]' \
|
||||
'(-)'{-v,--version}'[print version information]' \
|
||||
"(-i --interactive)"{-i,--interactive}'[read input from interactive CLI]: :->end' \
|
||||
"(-f --file)"{-f,--file}'[read input from <filename>]:nftables rule file:_files' \
|
||||
'(-c --check -n --numeric -N)'{-c,--check}"[check command's validity without actually applying the changes]" \
|
||||
'(-j --json)'{-j,--json}'[format output in json]' \
|
||||
'(-c --check -N)*'{-n,--numeric}'[can be specified up to 3 times, Shows 1:network addresses(default behaviour), 2:internet services (port numbers) and 3:protocols, user IDs, and group IDs numerically]' \
|
||||
'(-s --stateless)'{-s,--stateless}'[omit stateful information of ruleset]' \
|
||||
'(-N -n --numeric -c --check)'-N'[translate IP addresses to names]' \
|
||||
'(-a --handle)'{-a,--handle}'[output rule handle]' \
|
||||
'(-e --echo)'{-e,--echo}'[echo what has been added, inserted or replaced]' \
|
||||
{-I,--includepath}'[add specified directory to the paths searched for include files]:include directory [/usr/share]:include directory:_directories'
|
||||
)
|
||||
options=(
|
||||
'(-)'{-h,--help}'[show help]'
|
||||
'(-)'{-v,--version}'[print version information]'
|
||||
"(-i --interactive)"{-i,--interactive}'[read input from interactive CLI]: :->end'
|
||||
"(-f --file)"{-f,--file}'[read input from <filename>]:nftables rule file:_files'
|
||||
'(-c --check -n --numeric -N)'{-c,--check}"[check command's validity without actually applying the changes]"
|
||||
'(-j --json)'{-j,--json}'[format output in json]'
|
||||
'(-c --check -N)*'{-n,--numeric}'[can be specified up to 3 times, Shows 1:network addresses(default behaviour), 2:internet services (port numbers) and 3:protocols, user IDs, and group IDs numerically]'
|
||||
'(-s --stateless)'{-s,--stateless}'[omit stateful information of ruleset]'
|
||||
'(-N -n --numeric -c --check)'-N'[translate IP addresses to names]'
|
||||
'(-a --handle)'{-a,--handle}'[output rule handle]'
|
||||
'(-e --echo)'{-e,--echo}'[echo what has been added, inserted or replaced]'
|
||||
{-I,--includepath}'[add specified directory to the paths searched for include files]:include directory [/usr/share]:include directory:_directories'
|
||||
)
|
||||
|
||||
# start a state machine. The state is modified by _arguments if the
|
||||
# current argument (descriptors) cannot be completed. Each state has to define is successive state and the
|
||||
# 'descriptors' for _arguments, which essentially tells _arguments how to complete
|
||||
local _i=0
|
||||
while true;do
|
||||
(( _i+=1 ))
|
||||
#Guard for endless loops
|
||||
[[ $_i -gt 100 ]] && return 1
|
||||
# start a state machine. The state is modified by _arguments if the
|
||||
# current argument (descriptors) cannot be completed. Each state has to define is successive state and the
|
||||
# 'descriptors' for _arguments, which essentially tells _arguments how to complete
|
||||
local _i=0
|
||||
while true;do
|
||||
(( _i+=1 ))
|
||||
#Guard for endless loops
|
||||
[[ $_i -gt 100 ]] && return 1
|
||||
|
||||
descriptors=()
|
||||
nextstate="end"
|
||||
case $state in
|
||||
(start)
|
||||
##if line is empty (at the start) or ends with semicolon, autocomplete subcommands,
|
||||
# else if we are after a space,complete a semicolon (end the current nft command) and start anew
|
||||
if [[ $line[1] = "" || $line[1] =~ ';$' ]] ; then
|
||||
descriptors=( ":: :_nft_subcommands" )
|
||||
nextstate="category"
|
||||
else
|
||||
if [[ $words =~ ' $' ]]; then
|
||||
descriptors=(':: :(\;)')
|
||||
else
|
||||
descriptors=(':argument: ')
|
||||
fi
|
||||
descriptors=()
|
||||
nextstate="end"
|
||||
case $state in
|
||||
(start)
|
||||
##if line is empty (at the start) or ends with semicolon, autocomplete subcommands,
|
||||
# else if we are after a space,complete a semicolon (end the current nft command) and start anew
|
||||
if [[ $line[1] = "" || $line[1] =~ ';$' ]] ; then
|
||||
descriptors=( ":: :_nft_subcommands" )
|
||||
nextstate="category"
|
||||
else
|
||||
if [[ $words =~ ' $' ]]; then
|
||||
descriptors=(':: :(\;)')
|
||||
else
|
||||
descriptors=(':argument: ')
|
||||
fi
|
||||
nextstate="start"
|
||||
fi
|
||||
;;
|
||||
(category)
|
||||
case $line[1] in
|
||||
(add | list | flush | delete | create | rename | insert | replace | reset)
|
||||
descriptors=( ":: :_nft_${line[1]}" )
|
||||
nextstate=$line[1]
|
||||
;;
|
||||
(monitor)
|
||||
descriptors=( ":: : _nft_mon_filter" )
|
||||
nextstate="mon1"
|
||||
;;
|
||||
(export)
|
||||
descriptors=( ":: :(ruleset)" ":: :_nft_out_format" )
|
||||
nextstate="preend"
|
||||
;;
|
||||
(describe)
|
||||
descriptors=( ":expression: ")
|
||||
nextstate="start" #x restart
|
||||
;;
|
||||
(*)
|
||||
return 1;
|
||||
;;
|
||||
esac
|
||||
|
||||
#descriptors=( "(ruleset)" )
|
||||
#nextstate="end"
|
||||
;;
|
||||
(mon1)
|
||||
case $line[1] in
|
||||
(new | destroy)
|
||||
# descriptors=( ":: :_nft_mon_keywords" ":: :_nft_out_format")
|
||||
descriptors=( ":: : _nft_mon_keywords")
|
||||
nextstate="mon1"
|
||||
;;
|
||||
(tables | chains | sets | rules | elements | ruleset)
|
||||
descriptors=( ":: : _nft_out_format")
|
||||
nextstate="preend"
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
#all completions for create and insert match with the completions of add
|
||||
(create | insert)
|
||||
state="add"
|
||||
;|
|
||||
#all completions for reset and flush match with the completions of list
|
||||
(reset | flush)
|
||||
state="list"
|
||||
;|
|
||||
#(add(^table)/create(^table)/delete/flush(^ruleset)/insert/list(^ruleset)/rename/replace)[family]table
|
||||
(reset | delete | insert | rename | replace | add | create | flush | list)
|
||||
if [[ $state = "add" && $line[1] = "table" ]]; then
|
||||
descriptors=( ":: :_nft_families" ":table name:")
|
||||
nextstate="start" #x restart
|
||||
elif [[ $state = "list" && ( $line[1] = "ruleset" || $line[1] = "tables" ) ]]; then
|
||||
descriptors=( ":: :_nft_families")
|
||||
nextstate="start" #x restart
|
||||
elif [[ $state = "delete" && $line[1] = "table" ]]; then
|
||||
descriptors=(": : _nft_table all-handle")
|
||||
nextstate="tcomplete-delete-table"
|
||||
else
|
||||
cmd_obj=$line[1]
|
||||
cmd_subcmd=$state
|
||||
descriptors=(": : _nft_table all")
|
||||
nextstate="tcomplete"
|
||||
fi
|
||||
;;
|
||||
(tcomplete-delete-table)
|
||||
# if only a family was completed, complete the table name.
|
||||
case $line[1] in
|
||||
(arp | bridge | inet | ip | ip6 | netdev)
|
||||
descriptors=(": : _nft_table ${line[1]}-handle")
|
||||
cmd_fam=$line[1]
|
||||
;;
|
||||
# if 'handle' was completed, complete the handle number.
|
||||
(handle)
|
||||
descriptors=(": : _nft_table_handle_all " )
|
||||
;;
|
||||
# else, complete nothing and go to the next state. default family is 'ip'
|
||||
(*)
|
||||
descriptors=()
|
||||
cmd_fam="ip"
|
||||
;;
|
||||
esac
|
||||
nextstate="delete-table"
|
||||
;;
|
||||
(tcomplete)
|
||||
# if only a family was completed, complete the table name.
|
||||
case $line[1] in
|
||||
(arp | bridge | inet | ip | ip6 | netdev)
|
||||
descriptors=(": : _nft_table ${line[1]}")
|
||||
cmd_fam=$line[1]
|
||||
;;
|
||||
# else, complete nothing and go to the next state. default family is 'ip'
|
||||
(*)
|
||||
descriptors=()
|
||||
cmd_fam="ip"
|
||||
;;
|
||||
esac
|
||||
nextstate="$cmd_subcmd-$cmd_obj"
|
||||
;;
|
||||
(list-table)
|
||||
descriptors=(":: :(\;)")
|
||||
nextstate="start"
|
||||
;;
|
||||
(delete-table)
|
||||
#if family AND handle were input, complete handle number for given family.
|
||||
if [[ $line[1] == "handle" ]]; then
|
||||
descriptors=(":table handle: _nft_table_handle $cmd_fam" )
|
||||
else
|
||||
descriptors=()
|
||||
fi
|
||||
nextstate="start"
|
||||
;;
|
||||
(delete-chain | delete-set | delete-quota | delete-counter | delete-ct\\ helper)
|
||||
cmd_tab=$line[1]
|
||||
descriptors=(": : _nft_object $cmd_fam $cmd_tab $cmd_obj true")
|
||||
nextstate="delete-obj-handle"
|
||||
;;
|
||||
(delete-obj-handle)
|
||||
if [[ $line[1] == "handle" ]]; then
|
||||
descriptors=(": : _nft_object_handle $cmd_fam $cmd_tab $cmd_obj")
|
||||
else
|
||||
descriptors=(": :(\;)")
|
||||
fi
|
||||
nextstate="start"
|
||||
;;
|
||||
(add-chain)
|
||||
descriptors=(":chain name:")
|
||||
nextstate="start"
|
||||
;;
|
||||
(rename-chain)
|
||||
cmd_tab=$line[1]
|
||||
descriptors=(": : _nft_object $cmd_fam $cmd_tab chain false")
|
||||
nextstate="add-chain"
|
||||
;;
|
||||
(replace-rule | delete-rule)
|
||||
cmd_tab=$line[1]
|
||||
descriptors=(": : _nft_object $cmd_fam $cmd_tab chain false")
|
||||
nextstate="repdel-rule"
|
||||
;;
|
||||
(repdel-rule)
|
||||
cmd_chain=$line[1]
|
||||
descriptors=(": :(handle)" ": : _nft_rule_handle $cmd_fam $cmd_tab ${line[1]}")
|
||||
if [[ $cmd_subcmd = "replace" ]];then
|
||||
nextstate="rule-stmt"
|
||||
else
|
||||
nextstate="start"
|
||||
fi
|
||||
;;
|
||||
(add-rule)
|
||||
cmd_tab=$line[1]
|
||||
descriptors=(": : _nft_object $cmd_fam $cmd_tab chain false")
|
||||
nextstate="add-rule-2"
|
||||
;;
|
||||
(add-rule-2)
|
||||
cmd_chain=$line[1]
|
||||
descriptors=(": :(handle index position)")
|
||||
nextstate="add-rule-3"
|
||||
;;
|
||||
(add-rule-3)
|
||||
case $line[1] in
|
||||
(index | position)
|
||||
descriptors=(":${line[1]}:")
|
||||
;;
|
||||
(handle)
|
||||
descriptors=(": : _nft_rule_handle $cmd_fam $cmd_tab $cmd_chain")
|
||||
;;
|
||||
(*)
|
||||
descriptors=()
|
||||
;;
|
||||
esac
|
||||
nextstate="rule-stmt"
|
||||
;;
|
||||
(rule-stmt)
|
||||
#TODO
|
||||
# _nft_rule $cmd_fam $cmd_tab $cmd_chain\
|
||||
# && return 0;
|
||||
descriptors=(":expression: ")
|
||||
nextstate="start"
|
||||
;;
|
||||
(list-set | list-map | delete-map | list-chain | list-flowtable | delete-flowtable | list-ct\\ helper | list-counter | list-quota | list-meter)
|
||||
cmd_tab=$line[1]
|
||||
descriptors=(": : _nft_object $cmd_fam $cmd_tab $cmd_obj false")
|
||||
nextstate="start"
|
||||
fi
|
||||
;;
|
||||
(category)
|
||||
case $line[1] in
|
||||
(add | list | flush | delete | create | rename | insert | replace | reset)
|
||||
descriptors=( ":: :_nft_${line[1]}" )
|
||||
nextstate=$line[1]
|
||||
;;
|
||||
(monitor)
|
||||
descriptors=( ":: : _nft_mon_filter" )
|
||||
nextstate="mon1"
|
||||
;;
|
||||
(export)
|
||||
descriptors=( ":: :(ruleset)" ":: :_nft_out_format" )
|
||||
nextstate="preend"
|
||||
;;
|
||||
(describe)
|
||||
descriptors=( ":expression: ")
|
||||
nextstate="start" #x restart
|
||||
;;
|
||||
(*)
|
||||
return 1;
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
(add-element | delete-element)
|
||||
cmd_tab=$line[1]
|
||||
descriptors=(": : _nft_object $cmd_fam $cmd_tab '\(map\|set\)' false")
|
||||
nextstate="start"
|
||||
;;
|
||||
#TODO:
|
||||
#(add-set | add-map)
|
||||
#(add-flowtable)
|
||||
#("add-ct\ helper")
|
||||
#(add-counter)
|
||||
#(add-quota)
|
||||
|
||||
#descriptors=( "(ruleset)" )
|
||||
#nextstate="end"
|
||||
;;
|
||||
(mon1)
|
||||
case $line[1] in
|
||||
(new | destroy)
|
||||
# descriptors=( ":: :_nft_mon_keywords" ":: :_nft_out_format")
|
||||
descriptors=( ":: : _nft_mon_keywords")
|
||||
nextstate="mon1"
|
||||
;;
|
||||
(tables | chains | sets | rules | elements | ruleset)
|
||||
descriptors=( ":: : _nft_out_format")
|
||||
nextstate="preend"
|
||||
;;
|
||||
(*)
|
||||
return 1;
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
#all completions for create and insert match with the completions of add
|
||||
(create | insert)
|
||||
state="add"
|
||||
;|
|
||||
#all completions for reset and flush match with the completions of list
|
||||
(reset | flush)
|
||||
state="list"
|
||||
;|
|
||||
#(add(^table)/create(^table)/delete/flush(^ruleset)/insert/list(^ruleset)/rename/replace)[family]table
|
||||
(reset | delete | insert | rename | replace | add | create | flush | list)
|
||||
if [[ $state = "add" && $line[1] = "table" ]]; then
|
||||
descriptors=( ":: :_nft_families" ":table name:")
|
||||
nextstate="start" #x restart
|
||||
elif [[ $state = "list" && ( $line[1] = "ruleset" || $line[1] = "tables" ) ]]; then
|
||||
descriptors=( ":: :_nft_families")
|
||||
nextstate="start" #x restart
|
||||
elif [[ $state = "delete" && $line[1] = "table" ]]; then
|
||||
descriptors=(": : _nft_table all-handle")
|
||||
nextstate="tcomplete-delete-table"
|
||||
else
|
||||
cmd_obj=$line[1]
|
||||
cmd_subcmd=$state
|
||||
descriptors=(": : _nft_table all")
|
||||
nextstate="tcomplete"
|
||||
fi
|
||||
;;
|
||||
(tcomplete-delete-table)
|
||||
# if only a family was completed, complete the table name.
|
||||
case $line[1] in
|
||||
(arp | bridge | inet | ip | ip6 | netdev)
|
||||
descriptors=(": : _nft_table ${line[1]}-handle")
|
||||
cmd_fam=$line[1]
|
||||
;;
|
||||
# if 'handle' was completed, complete the handle number.
|
||||
(handle)
|
||||
descriptors=(": : _nft_table_handle_all " )
|
||||
;;
|
||||
# else, complete nothing and go to the next state. default family is 'ip'
|
||||
(*)
|
||||
descriptors=()
|
||||
cmd_fam="ip"
|
||||
;;
|
||||
esac
|
||||
nextstate="delete-table"
|
||||
;;
|
||||
(tcomplete)
|
||||
# if only a family was completed, complete the table name.
|
||||
case $line[1] in
|
||||
(arp | bridge | inet | ip | ip6 | netdev)
|
||||
descriptors=(": : _nft_table ${line[1]}")
|
||||
cmd_fam=$line[1]
|
||||
;;
|
||||
# else, complete nothing and go to the next state. default family is 'ip'
|
||||
(*)
|
||||
descriptors=()
|
||||
cmd_fam="ip"
|
||||
;;
|
||||
esac
|
||||
nextstate="$cmd_subcmd-$cmd_obj"
|
||||
;;
|
||||
(list-table)
|
||||
descriptors=(":: :(\;)")
|
||||
nextstate="start"
|
||||
;;
|
||||
(delete-table)
|
||||
#if family AND handle were input, complete handle number for given family.
|
||||
if [[ $line[1] == "handle" ]]; then
|
||||
descriptors=(":table handle: _nft_table_handle $cmd_fam" )
|
||||
else
|
||||
descriptors=()
|
||||
fi
|
||||
nextstate="start"
|
||||
;;
|
||||
(delete-chain | delete-set | delete-quota | delete-counter | delete-ct\\ helper)
|
||||
cmd_tab=$line[1]
|
||||
descriptors=(": : _nft_object $cmd_fam $cmd_tab $cmd_obj true")
|
||||
nextstate="delete-obj-handle"
|
||||
;;
|
||||
(delete-obj-handle)
|
||||
if [[ $line[1] == "handle" ]]; then
|
||||
descriptors=(": : _nft_object_handle $cmd_fam $cmd_tab $cmd_obj")
|
||||
else
|
||||
descriptors=(": :(\;)")
|
||||
fi
|
||||
nextstate="start"
|
||||
;;
|
||||
(add-chain)
|
||||
descriptors=(":chain name:")
|
||||
nextstate="start"
|
||||
;;
|
||||
(rename-chain)
|
||||
cmd_tab=$line[1]
|
||||
descriptors=(": : _nft_object $cmd_fam $cmd_tab chain false")
|
||||
nextstate="add-chain"
|
||||
;;
|
||||
(replace-rule | delete-rule)
|
||||
cmd_tab=$line[1]
|
||||
descriptors=(": : _nft_object $cmd_fam $cmd_tab chain false")
|
||||
nextstate="repdel-rule"
|
||||
;;
|
||||
(repdel-rule)
|
||||
cmd_chain=$line[1]
|
||||
descriptors=(": :(handle)" ": : _nft_rule_handle $cmd_fam $cmd_tab ${line[1]}")
|
||||
if [[ $cmd_subcmd = "replace" ]];then
|
||||
nextstate="rule-stmt"
|
||||
else
|
||||
nextstate="start"
|
||||
fi
|
||||
;;
|
||||
(add-rule)
|
||||
cmd_tab=$line[1]
|
||||
descriptors=(": : _nft_object $cmd_fam $cmd_tab chain false")
|
||||
nextstate="add-rule-2"
|
||||
;;
|
||||
(add-rule-2)
|
||||
cmd_chain=$line[1]
|
||||
descriptors=(": :(handle index position)")
|
||||
nextstate="add-rule-3"
|
||||
;;
|
||||
(add-rule-3)
|
||||
case $line[1] in
|
||||
(index | position)
|
||||
descriptors=(":${line[1]}:")
|
||||
;;
|
||||
(handle)
|
||||
descriptors=(": : _nft_rule_handle $cmd_fam $cmd_tab $cmd_chain")
|
||||
;;
|
||||
(*)
|
||||
descriptors=()
|
||||
;;
|
||||
esac
|
||||
nextstate="rule-stmt"
|
||||
;;
|
||||
(rule-stmt)
|
||||
#TODO
|
||||
# _nft_rule $cmd_fam $cmd_tab $cmd_chain\
|
||||
# && return 0;
|
||||
descriptors=(":expression: ")
|
||||
nextstate="start"
|
||||
;;
|
||||
(list-set | list-map | delete-map | list-chain | list-flowtable | delete-flowtable | list-ct\\ helper | list-counter | list-quota | list-meter)
|
||||
cmd_tab=$line[1]
|
||||
descriptors=(": : _nft_object $cmd_fam $cmd_tab $cmd_obj false")
|
||||
nextstate="start"
|
||||
;;
|
||||
(add-element | delete-element)
|
||||
cmd_tab=$line[1]
|
||||
descriptors=(": : _nft_object $cmd_fam $cmd_tab '\(map\|set\)' false")
|
||||
nextstate="start"
|
||||
;;
|
||||
#TODO:
|
||||
#(add-set | add-map)
|
||||
#(add-flowtable)
|
||||
#("add-ct\ helper")
|
||||
#(add-counter)
|
||||
#(add-quota)
|
||||
_arguments -C -s \
|
||||
"${options[@]}" \
|
||||
"${descriptors[@]}" \
|
||||
"*:: :->$nextstate" \
|
||||
&& return 0;
|
||||
|
||||
(*)
|
||||
return 1;
|
||||
;;
|
||||
esac
|
||||
_arguments -C -s \
|
||||
"${options[@]}" \
|
||||
"${descriptors[@]}" \
|
||||
"*:: :->$nextstate" \
|
||||
&& return 0;
|
||||
|
||||
done
|
||||
done
|
||||
} # end _nft
|
||||
|
||||
_nft_subcommands(){
|
||||
local commands=(
|
||||
'add:add a table, chain, rule, set, map, or object'
|
||||
'list:list a ruleset, table, chain, set, map, or object'
|
||||
'flush:flush (delete everything from) a ruleset, table, chain, set, or map'
|
||||
'export:print the ruleset in a machine readable format (json or xml)'
|
||||
'delete:delete a table, chain, rule, set, element, map, or object'
|
||||
'create:similar to add but returns an error for existing chain'
|
||||
'rename:rename the specified chain'
|
||||
'insert:similar to the add command, but the rule is prepended to the beginning of the chain or before the rule at the given position'
|
||||
'replace:similar to the add command, but replaces the specified rule'
|
||||
'reset:list-and-reset stateful object'
|
||||
'monitor:listen to Netlink events'
|
||||
'describe:show information about the type of an expression and its data type'
|
||||
'add:add a table, chain, rule, set, map, or object'
|
||||
'list:list a ruleset, table, chain, set, map, or object'
|
||||
'flush:flush (delete everything from) a ruleset, table, chain, set, or map'
|
||||
'export:print the ruleset in a machine readable format (json or xml)'
|
||||
'delete:delete a table, chain, rule, set, element, map, or object'
|
||||
'create:similar to add but returns an error for existing chain'
|
||||
'rename:rename the specified chain'
|
||||
'insert:similar to the add command, but the rule is prepended to the beginning of the chain or before the rule at the given position'
|
||||
'replace:similar to the add command, but replaces the specified rule'
|
||||
'reset:list-and-reset stateful object'
|
||||
'monitor:listen to Netlink events'
|
||||
'describe:show information about the type of an expression and its data type'
|
||||
)
|
||||
_describe -t commands 'nft subcommand' commands "$@"
|
||||
}
|
||||
|
||||
_nft_mon_filter(){
|
||||
local monitor_filters=(
|
||||
'new:show only events of created objects'
|
||||
|
|
|
|||
386
src/_openssl
386
src/_openssl
|
|
@ -1112,22 +1112,22 @@ _openssl_genpkey() {
|
|||
done
|
||||
|
||||
_arguments \
|
||||
'(- *)-help[print help message]' \
|
||||
'-out[output private key file]:file:_files' \
|
||||
'-outpubkey[output public key file]:file:_files' \
|
||||
'-outform[output format]:format:(DER PEM)' \
|
||||
'-verbose[output "status dots" while generating keys]' \
|
||||
'-quiet[do not output "status dots" while generating keys]' \
|
||||
'-pass[output file password source]:source:_openssl_pass_phrase_options' \
|
||||
$cipher_flags[@] \
|
||||
'-algorithm[public key algorithm]:alg:(($builtin_algorithms))' \
|
||||
'-pkeyopt[public key algorithm option]:option' \
|
||||
'-genparam[generate a set of parameters instead of a private key]' \
|
||||
'-paramfile[file to supply public key parameters]:file:_files' \
|
||||
'-text[print an (unencrypted) text representation of private and public keys and parameters]' \
|
||||
$openssl_random_state_options[@] \
|
||||
$openssl_provider_options[@] \
|
||||
'-config[configuration file]:file:_files'
|
||||
'(- *)-help[print help message]' \
|
||||
'-out[output private key file]:file:_files' \
|
||||
'-outpubkey[output public key file]:file:_files' \
|
||||
'-outform[output format]:format:(DER PEM)' \
|
||||
'-verbose[output "status dots" while generating keys]' \
|
||||
'-quiet[do not output "status dots" while generating keys]' \
|
||||
'-pass[output file password source]:source:_openssl_pass_phrase_options' \
|
||||
$cipher_flags[@] \
|
||||
'-algorithm[public key algorithm]:alg:(($builtin_algorithms))' \
|
||||
'-pkeyopt[public key algorithm option]:option' \
|
||||
'-genparam[generate a set of parameters instead of a private key]' \
|
||||
'-paramfile[file to supply public key parameters]:file:_files' \
|
||||
'-text[print an (unencrypted) text representation of private and public keys and parameters]' \
|
||||
$openssl_random_state_options[@] \
|
||||
$openssl_provider_options[@] \
|
||||
'-config[configuration file]:file:_files'
|
||||
}
|
||||
|
||||
_openssl_genrsa() {
|
||||
|
|
@ -1441,17 +1441,17 @@ _openssl_pkcs12() {
|
|||
|
||||
_openssl_pkcs7() {
|
||||
_arguments \
|
||||
'(- *)-help[print help message]' \
|
||||
'-inform[input format]:format:(DER PEM)' \
|
||||
'-outform[output format]:format:(DER PEM)' \
|
||||
'-in[input file name]:file:_files' \
|
||||
'-out[output file name]:file:_files' \
|
||||
'-print[print out the full PKCS7 object]' \
|
||||
'-print_certs[print out any certificates or CRLs contained in the file]' \
|
||||
'-quiet[print out just the PEM-encoded certificates without any other output]' \
|
||||
'-text[print out certificate details in full]' \
|
||||
'-noout[do not output the encoded version of the PKCS#7 structure]' \
|
||||
$openssl_provider_options[@]
|
||||
'(- *)-help[print help message]' \
|
||||
'-inform[input format]:format:(DER PEM)' \
|
||||
'-outform[output format]:format:(DER PEM)' \
|
||||
'-in[input file name]:file:_files' \
|
||||
'-out[output file name]:file:_files' \
|
||||
'-print[print out the full PKCS7 object]' \
|
||||
'-print_certs[print out any certificates or CRLs contained in the file]' \
|
||||
'-quiet[print out just the PEM-encoded certificates without any other output]' \
|
||||
'-text[print out certificate details in full]' \
|
||||
'-noout[do not output the encoded version of the PKCS#7 structure]' \
|
||||
$openssl_provider_options[@]
|
||||
}
|
||||
|
||||
_openssl_pkcs8() {
|
||||
|
|
@ -1460,51 +1460,51 @@ _openssl_pkcs8() {
|
|||
)
|
||||
|
||||
_arguments \
|
||||
'(- *)-help[print help message]' \
|
||||
'-topk8[read a private key and write a PkCS#8 format key]' \
|
||||
'-inform[input format]:format:(DER PEM)' \
|
||||
'-outform[output format]:format:(DER PEM)' \
|
||||
'-traditional[traditional format]' \
|
||||
'-in[input file name]:file:_files' \
|
||||
'-passin[input password source]:source:_openssl_pass_phrase_options' \
|
||||
'-passout[output password source]:source:_openssl_pass_phrase_options' \
|
||||
'-out[output file name]:files:_files' \
|
||||
'-iter[number of iterations to create PKCS#8 containers]:count' \
|
||||
'-noiter[use 1 as iteration count]' \
|
||||
'-nocrypt[output unencrypted PrivateKeyInfo structure]' \
|
||||
'-v2[algorithm for PKCS#5 v2.0]:alg:_openssl_cipher_algorithms' \
|
||||
'-v2prf[PRF algorithm to use with PKCS#5 v2.0]:alg:(($prf_algorithms))' \
|
||||
'-v1[algorithm for PKCS#5 v1.5 or PKCS#12]:alg:_openssl_cipher_algorithms' \
|
||||
'-scrypt[use the script algorithm for private key encryption]' \
|
||||
'-scrypt_N[scrypt "N" parameter]:n' \
|
||||
'-scrypt_r[scrypt "r" parameter]:r' \
|
||||
'-scrypt_p[scrypt "p" parameter]:p' \
|
||||
'-saltlen[length of the salt to use for the PBE algorithm]:length' \
|
||||
$openssl_random_state_options[@] \
|
||||
$openssl_provider_options[@]
|
||||
'(- *)-help[print help message]' \
|
||||
'-topk8[read a private key and write a PkCS#8 format key]' \
|
||||
'-inform[input format]:format:(DER PEM)' \
|
||||
'-outform[output format]:format:(DER PEM)' \
|
||||
'-traditional[traditional format]' \
|
||||
'-in[input file name]:file:_files' \
|
||||
'-passin[input password source]:source:_openssl_pass_phrase_options' \
|
||||
'-passout[output password source]:source:_openssl_pass_phrase_options' \
|
||||
'-out[output file name]:files:_files' \
|
||||
'-iter[number of iterations to create PKCS#8 containers]:count' \
|
||||
'-noiter[use 1 as iteration count]' \
|
||||
'-nocrypt[output unencrypted PrivateKeyInfo structure]' \
|
||||
'-v2[algorithm for PKCS#5 v2.0]:alg:_openssl_cipher_algorithms' \
|
||||
'-v2prf[PRF algorithm to use with PKCS#5 v2.0]:alg:(($prf_algorithms))' \
|
||||
'-v1[algorithm for PKCS#5 v1.5 or PKCS#12]:alg:_openssl_cipher_algorithms' \
|
||||
'-scrypt[use the script algorithm for private key encryption]' \
|
||||
'-scrypt_N[scrypt "N" parameter]:n' \
|
||||
'-scrypt_r[scrypt "r" parameter]:r' \
|
||||
'-scrypt_p[scrypt "p" parameter]:p' \
|
||||
'-saltlen[length of the salt to use for the PBE algorithm]:length' \
|
||||
$openssl_random_state_options[@] \
|
||||
$openssl_provider_options[@]
|
||||
}
|
||||
|
||||
_openssl_pkey() {
|
||||
_arguments \
|
||||
'(- *)-help[print help message]' \
|
||||
$openssl_provider_options[@] \
|
||||
'-check[check the consistency of a key pair for both public and private components]' \
|
||||
'-pubcheck[check the correctness of either a public key or the public components of a key pair]' \
|
||||
'-in[input file or URI]:file_or_uri:_files' \
|
||||
'-inform[key input format]:format:(DER PEM P12 ENGINE)' \
|
||||
'-passin[password source for the key input]:source:_openssl_pass_phrase_options' \
|
||||
'-pubin[read public key instead of private key]' \
|
||||
'-out[output file name]' \
|
||||
'-outform[key output format]:format:(DER PEM)' \
|
||||
'-cipher[cipher to encrypt the PEM encoded private key]:cipher:_openssl_ciphers' \
|
||||
'-passout[password source for the output file]:source:_openssl_pass_phrase_options' \
|
||||
'-traditional[use older "traditional" format]' \
|
||||
'-pubout[output the public components]' \
|
||||
'-noout[do not output the key in encoded form]' \
|
||||
'-text[output the various key components in plain text]' \
|
||||
'-text_pub[output only the public key components in text form]' \
|
||||
'-ec_conv_form[specify how the points on the elliptic-curve curve are converted into octet strings]:type:(compressed uncompressed hybrid)' \
|
||||
'-ec_param_enc[specify how the elliptic curve parameters are encoded]:type:(named_curve explicit)'
|
||||
'(- *)-help[print help message]' \
|
||||
$openssl_provider_options[@] \
|
||||
'-check[check the consistency of a key pair for both public and private components]' \
|
||||
'-pubcheck[check the correctness of either a public key or the public components of a key pair]' \
|
||||
'-in[input file or URI]:file_or_uri:_files' \
|
||||
'-inform[key input format]:format:(DER PEM P12 ENGINE)' \
|
||||
'-passin[password source for the key input]:source:_openssl_pass_phrase_options' \
|
||||
'-pubin[read public key instead of private key]' \
|
||||
'-out[output file name]' \
|
||||
'-outform[key output format]:format:(DER PEM)' \
|
||||
'-cipher[cipher to encrypt the PEM encoded private key]:cipher:_openssl_ciphers' \
|
||||
'-passout[password source for the output file]:source:_openssl_pass_phrase_options' \
|
||||
'-traditional[use older "traditional" format]' \
|
||||
'-pubout[output the public components]' \
|
||||
'-noout[do not output the key in encoded form]' \
|
||||
'-text[output the various key components in plain text]' \
|
||||
'-text_pub[output only the public key components in text form]' \
|
||||
'-ec_conv_form[specify how the points on the elliptic-curve curve are converted into octet strings]:type:(compressed uncompressed hybrid)' \
|
||||
'-ec_param_enc[specify how the elliptic curve parameters are encoded]:type:(named_curve explicit)'
|
||||
}
|
||||
|
||||
_openssl_pkeyparam() {
|
||||
|
|
@ -1721,8 +1721,8 @@ _openssl_s_client() {
|
|||
local tls_start_protocols=(smtp pop3 imap ftp xmpp xmpp-server irc postgres mysql lmtp nntp sieve ldap)
|
||||
|
||||
_arguments \
|
||||
'(- *)-help[print help message]' \
|
||||
'-ssl_config[section of the configuration file to configure the SSL_CTX object]:section' \
|
||||
'(- *)-help[print help message]' \
|
||||
'-ssl_config[section of the configuration file to configure the SSL_CTX object]:section' \
|
||||
'-connect[host and optional port to connect to]:host_port' \
|
||||
'-host[host to connect to]:host' \
|
||||
'-port[port to connect to]:port' \
|
||||
|
|
@ -1835,129 +1835,129 @@ _openssl_s_client() {
|
|||
|
||||
_openssl_s_server() {
|
||||
_arguments \
|
||||
'(- *)-help[print help message]' \
|
||||
'-port[TCP port to listen on for connections(default: 4433)]:port' \
|
||||
'-accept[optional TCP host and port to listen on for connections(default: *:4433)]:host_port' \
|
||||
'-unix[Unix domain socket path]:path:_files' \
|
||||
'(-4 -6)-4[use IPv4 only]' \
|
||||
'(-4 -6)-6[use IPv6 only]' \
|
||||
'-unlink[for -unix, unlink any existing socket first]' \
|
||||
'-context[SSL context ID]:id' \
|
||||
'(-verify -Verify)'{-verify,-Verify}'[verify depth]:depth' \
|
||||
'-cert[certificate file]:file:_files' \
|
||||
'-cert2[certificate file to use for servername(default: server2.pem)]:file:_files' \
|
||||
'-certform[server certificate file format]:format:(DER PEM P12)' \
|
||||
'-cert_chain[file or URI of untrusted certificates to build the certificate chain]:file_or_uri:_files' \
|
||||
'-build_chain[application should build the server certificate chain]' \
|
||||
'-serverinfo[file containing one or more blocks of PEM data]:file:_files' \
|
||||
'-key[private key file or URI]:file_or_uri:_files' \
|
||||
'-key2[private key file or URI to use for servername]:file_or_uri:_files' \
|
||||
'-keyform[key format]:format:(DER PEM P12 ENGINE)' \
|
||||
'-pass[private key and certificate file password source]:source:_openssl_pass_phrase_options' \
|
||||
'-dcert[additional certificate file]:file:_files' \
|
||||
'-dkey[additional private key file or URI]:file_or_uri:_files' \
|
||||
'-dcert_chain[file or URI of untrusted certificates to build the server certificate chain]:file_or_uri:_files' \
|
||||
'-dcertform[format of the additional certificate file]:format:(DER PEM P12)' \
|
||||
'-dkeyform[format of the additional private key]:format:(DER PEM P12 ENGINE)' \
|
||||
'-dpass[passphrase for the additional private key and certificate]:pass:_openssl_pass_phrase_options' \
|
||||
'-nbio_test[test non blocking I/O]' \
|
||||
'-crlf[translate a line feed from the terminal into CR+LF]' \
|
||||
'-debug[print extensive debugging information including a hex dump of all traffic]' \
|
||||
'-security_debug[print output from SSL/TLS security framework]' \
|
||||
'-security_debug_verbose[print more output from SSL/TLS security framework]' \
|
||||
'-msg[show all protocol messages with hex dump]' \
|
||||
'-msgfile[file to send output of -msg or -trace to]:file:_files' \
|
||||
'-state[print the SSL session states]' \
|
||||
'-CRL[CRL file]:file:_files' \
|
||||
'-CRLform[CRL file format]:format:(DER PEM)' \
|
||||
'-crl_download[download CRLs from distribution points]' \
|
||||
'-verifyCAfile[file in PEM format CA containing trusted certificates to verify client certificates]:file:_files' \
|
||||
'-verifyCApath[directory containing trusted certificates to verify client certificates]:dir:_files -/' \
|
||||
'-verifyCAstore[URI of a store containing trusted certificates to verify client certificates]:uri:_urls' \
|
||||
'-chainCAfile[file in PEM format containing trusted certificates to build the server certificate chain]:file:_files' \
|
||||
'-chainCApath[directory containing trusted certificates for building server certificate chain]:dir:_files -/' \
|
||||
'-chainCAstore[URI of a store containing trusted certificates for building server certificate chain]:uri:_urls' \
|
||||
'-nocert[no certificate is used]' \
|
||||
'-quiet[inhibit printing of session and certificate information]' \
|
||||
'-no_resume_ephemeral[disable caching and tickets if ephemeral (EC)DH is used]' \
|
||||
'-tlsextdebug[print a hex dump of any TLS extensions received from the server]' \
|
||||
'-www[send a status message back to the client when it connects]' \
|
||||
'(-WWW -HTTP)'{-WWW,-HTTP}'[emulate a simple web server]' \
|
||||
'-http_server_binmode[acting as web-server open files in binary mode]' \
|
||||
'-no_ca_names[disable TLS Extension CA Names]' \
|
||||
'-ignore_unexpected_eof[peer does not need to send the close_notify alert]' \
|
||||
'-servername[servername for HostName TLS extension]' \
|
||||
'-servername_fatal[send fatal alert on servername mismatch]' \
|
||||
'-id_prefix[generate SSL/TLS session IDs prefixed by this ID]:id' \
|
||||
'-keymatexport[export keying material using label]:label' \
|
||||
'-keymatexportlen[export the given number of bytes of keying material(default: 20)]:length' \
|
||||
'-no_cache[disable session cache]' \
|
||||
'-ext_cache[disable internal cache]' \
|
||||
'-verify_return_error[close the connection when verification errors occur]' \
|
||||
'-verify_quiet[no verify output except verify errors]' \
|
||||
'(-no_ign_eof -ign_eof)-ign_eof[ignore input EOF]' \
|
||||
'(-no_ign_eof -ign_eof)-no_ign_eof[do not ignore input EOF]' \
|
||||
'-no_ems[disable Extended master secret negotiation]' \
|
||||
'-status[enable certificate status request support]' \
|
||||
'-status_verbose[enable certificate status request support and verbose output of OCSP response]' \
|
||||
'-status_timeout[set the timeout for OCSP reponse to the given seconds]:seconds' \
|
||||
'-proxy[HTTP(S) proxy server]:proxy' \
|
||||
'-no_proxy[list of IP addresses and/or DNS names not to use an HTTP(S) proxy for]:addresses' \
|
||||
'-status_url[set a fallback responder URL]:url:_urls' \
|
||||
'-status_file[status file]:file:_files' \
|
||||
'-ssl_config[configure SSL_CTX using the given configure value]:config' \
|
||||
'-trace[show verbose trace output of protocol messages]' \
|
||||
'-brief[provide a brief summary of connection parameters]' \
|
||||
'-rev[simple echo server that sends back received text reserved]' \
|
||||
'-async[switch on asynchronous mode]' \
|
||||
'-max_send_frag[maximum size of data fragment to send]:size' \
|
||||
'-split_send_frag[size used to split data for encrypt pipelines]:size' \
|
||||
'-max_pipelines[maximum number of encrypt/decrypt pipelines]:number' \
|
||||
'-naccept[server will exit after receiving the specified number of connections(default: unlimited)]:number' \
|
||||
'-read_buf[default read buffer size for connections]:size' \
|
||||
'-no_tx_cert_comp[disable support for sending TLSv1.3 compressed certificates]' \
|
||||
'-no_rx_cert_comp[disable support for receiving TLSv1.3 compressed certificates]' \
|
||||
'-no_comp[disable negotiation of TLS compression]' \
|
||||
'-num_tickets[control the number of tickets that will be sent to the client after a full handshake in TLSv1.3]' \
|
||||
'-dhparam[DH parameter file to use]:file:_files' \
|
||||
'-nbio[turn on non blocking I/O]' \
|
||||
'-timeout[enable timeout]' \
|
||||
'-mtu[set link-layer MTU]:size' \
|
||||
'-psk_identity[PSK identify when using a PSK cipher suite]:id' \
|
||||
'-psk_hint[PSK identity hint when using a PSK cipher suite]:hint' \
|
||||
'-psk[PSK key when using a PSK cipher suite]:key' \
|
||||
'-psk_session[file contains pem encoded SSL_SESSION data]:file:_files' \
|
||||
'-srpvfile[verifier file for SRP]:file:_files' \
|
||||
'-listen[listen on a UDP port for incoming connections]' \
|
||||
'-sctp[use SCTP for the transport protocol instead of UDP in DTLS]' \
|
||||
'-sctp_label_bug[allow communication with older broken implementations]' \
|
||||
'-use_srtp[offer SRTP key management with a colon-separated profile list]:list' \
|
||||
'-no_dhe[no DH parameters will be loaded]' \
|
||||
'-alpn[enable the Application-Layer Protocol Negotiation extension]:protocol' \
|
||||
'-nextprotoneg[enable the Next Protocol Negotiation extension]:protocol' \
|
||||
'-ktls[enable kernel TLS for sending and receiving]' \
|
||||
'-sendfile[SSL_sendfile will be used instead of BIO_write to send response]' \
|
||||
'-zerocopy_sendfile[SSL_sendfile will use the zerocopy TX mode]' \
|
||||
'-keylogfile[append TLS secrets to the specified keylog file]:file:_files' \
|
||||
'-max_early_data[change the default maximum early data bytes for new sessions and incoming early data]:size' \
|
||||
'-recv_max_early_data[hard limit on the maximum number of early data bytes that will be accepted]:bytes' \
|
||||
'-early_data[accept early data where possible]' \
|
||||
'-stateless[require TLSv1.3 cookies]' \
|
||||
'(-anti_replay -no_anti_replay)-anti_replay[switch replay protection on]' \
|
||||
'(-anti_replay -no_anti_replay)-no_anti_replay[switch replay protection off]' \
|
||||
'-tfo[enable acceptance of TCP fast Open connections]' \
|
||||
'-cert_comp[pre-compresses certificates that will be sent during the handshake]' \
|
||||
'-nameopt[how the subject or issuer names are displayed]:how:_openssl_name_display_options' \
|
||||
$openssl_tls_flags[@] \
|
||||
$openssl_dtls_flags[@] \
|
||||
$openssl_supported_commands_flags[@] \
|
||||
$openssl_extended_verification_flags[@] \
|
||||
$openssl_trusted_certificate_options[@] \
|
||||
$openssl_random_state_options[@] \
|
||||
$openssl_provider_options[@] \
|
||||
$openssl_verification_options[@] \
|
||||
'-enable_server_rpk[enable support for sending raw public keys to the client]' \
|
||||
'-enable_client_rpk[enable support for receiving raw public keys from the client]'
|
||||
'(- *)-help[print help message]' \
|
||||
'-port[TCP port to listen on for connections(default: 4433)]:port' \
|
||||
'-accept[optional TCP host and port to listen on for connections(default: *:4433)]:host_port' \
|
||||
'-unix[Unix domain socket path]:path:_files' \
|
||||
'(-4 -6)-4[use IPv4 only]' \
|
||||
'(-4 -6)-6[use IPv6 only]' \
|
||||
'-unlink[for -unix, unlink any existing socket first]' \
|
||||
'-context[SSL context ID]:id' \
|
||||
'(-verify -Verify)'{-verify,-Verify}'[verify depth]:depth' \
|
||||
'-cert[certificate file]:file:_files' \
|
||||
'-cert2[certificate file to use for servername(default: server2.pem)]:file:_files' \
|
||||
'-certform[server certificate file format]:format:(DER PEM P12)' \
|
||||
'-cert_chain[file or URI of untrusted certificates to build the certificate chain]:file_or_uri:_files' \
|
||||
'-build_chain[application should build the server certificate chain]' \
|
||||
'-serverinfo[file containing one or more blocks of PEM data]:file:_files' \
|
||||
'-key[private key file or URI]:file_or_uri:_files' \
|
||||
'-key2[private key file or URI to use for servername]:file_or_uri:_files' \
|
||||
'-keyform[key format]:format:(DER PEM P12 ENGINE)' \
|
||||
'-pass[private key and certificate file password source]:source:_openssl_pass_phrase_options' \
|
||||
'-dcert[additional certificate file]:file:_files' \
|
||||
'-dkey[additional private key file or URI]:file_or_uri:_files' \
|
||||
'-dcert_chain[file or URI of untrusted certificates to build the server certificate chain]:file_or_uri:_files' \
|
||||
'-dcertform[format of the additional certificate file]:format:(DER PEM P12)' \
|
||||
'-dkeyform[format of the additional private key]:format:(DER PEM P12 ENGINE)' \
|
||||
'-dpass[passphrase for the additional private key and certificate]:pass:_openssl_pass_phrase_options' \
|
||||
'-nbio_test[test non blocking I/O]' \
|
||||
'-crlf[translate a line feed from the terminal into CR+LF]' \
|
||||
'-debug[print extensive debugging information including a hex dump of all traffic]' \
|
||||
'-security_debug[print output from SSL/TLS security framework]' \
|
||||
'-security_debug_verbose[print more output from SSL/TLS security framework]' \
|
||||
'-msg[show all protocol messages with hex dump]' \
|
||||
'-msgfile[file to send output of -msg or -trace to]:file:_files' \
|
||||
'-state[print the SSL session states]' \
|
||||
'-CRL[CRL file]:file:_files' \
|
||||
'-CRLform[CRL file format]:format:(DER PEM)' \
|
||||
'-crl_download[download CRLs from distribution points]' \
|
||||
'-verifyCAfile[file in PEM format CA containing trusted certificates to verify client certificates]:file:_files' \
|
||||
'-verifyCApath[directory containing trusted certificates to verify client certificates]:dir:_files -/' \
|
||||
'-verifyCAstore[URI of a store containing trusted certificates to verify client certificates]:uri:_urls' \
|
||||
'-chainCAfile[file in PEM format containing trusted certificates to build the server certificate chain]:file:_files' \
|
||||
'-chainCApath[directory containing trusted certificates for building server certificate chain]:dir:_files -/' \
|
||||
'-chainCAstore[URI of a store containing trusted certificates for building server certificate chain]:uri:_urls' \
|
||||
'-nocert[no certificate is used]' \
|
||||
'-quiet[inhibit printing of session and certificate information]' \
|
||||
'-no_resume_ephemeral[disable caching and tickets if ephemeral (EC)DH is used]' \
|
||||
'-tlsextdebug[print a hex dump of any TLS extensions received from the server]' \
|
||||
'-www[send a status message back to the client when it connects]' \
|
||||
'(-WWW -HTTP)'{-WWW,-HTTP}'[emulate a simple web server]' \
|
||||
'-http_server_binmode[acting as web-server open files in binary mode]' \
|
||||
'-no_ca_names[disable TLS Extension CA Names]' \
|
||||
'-ignore_unexpected_eof[peer does not need to send the close_notify alert]' \
|
||||
'-servername[servername for HostName TLS extension]' \
|
||||
'-servername_fatal[send fatal alert on servername mismatch]' \
|
||||
'-id_prefix[generate SSL/TLS session IDs prefixed by this ID]:id' \
|
||||
'-keymatexport[export keying material using label]:label' \
|
||||
'-keymatexportlen[export the given number of bytes of keying material(default: 20)]:length' \
|
||||
'-no_cache[disable session cache]' \
|
||||
'-ext_cache[disable internal cache]' \
|
||||
'-verify_return_error[close the connection when verification errors occur]' \
|
||||
'-verify_quiet[no verify output except verify errors]' \
|
||||
'(-no_ign_eof -ign_eof)-ign_eof[ignore input EOF]' \
|
||||
'(-no_ign_eof -ign_eof)-no_ign_eof[do not ignore input EOF]' \
|
||||
'-no_ems[disable Extended master secret negotiation]' \
|
||||
'-status[enable certificate status request support]' \
|
||||
'-status_verbose[enable certificate status request support and verbose output of OCSP response]' \
|
||||
'-status_timeout[set the timeout for OCSP reponse to the given seconds]:seconds' \
|
||||
'-proxy[HTTP(S) proxy server]:proxy' \
|
||||
'-no_proxy[list of IP addresses and/or DNS names not to use an HTTP(S) proxy for]:addresses' \
|
||||
'-status_url[set a fallback responder URL]:url:_urls' \
|
||||
'-status_file[status file]:file:_files' \
|
||||
'-ssl_config[configure SSL_CTX using the given configure value]:config' \
|
||||
'-trace[show verbose trace output of protocol messages]' \
|
||||
'-brief[provide a brief summary of connection parameters]' \
|
||||
'-rev[simple echo server that sends back received text reserved]' \
|
||||
'-async[switch on asynchronous mode]' \
|
||||
'-max_send_frag[maximum size of data fragment to send]:size' \
|
||||
'-split_send_frag[size used to split data for encrypt pipelines]:size' \
|
||||
'-max_pipelines[maximum number of encrypt/decrypt pipelines]:number' \
|
||||
'-naccept[server will exit after receiving the specified number of connections(default: unlimited)]:number' \
|
||||
'-read_buf[default read buffer size for connections]:size' \
|
||||
'-no_tx_cert_comp[disable support for sending TLSv1.3 compressed certificates]' \
|
||||
'-no_rx_cert_comp[disable support for receiving TLSv1.3 compressed certificates]' \
|
||||
'-no_comp[disable negotiation of TLS compression]' \
|
||||
'-num_tickets[control the number of tickets that will be sent to the client after a full handshake in TLSv1.3]' \
|
||||
'-dhparam[DH parameter file to use]:file:_files' \
|
||||
'-nbio[turn on non blocking I/O]' \
|
||||
'-timeout[enable timeout]' \
|
||||
'-mtu[set link-layer MTU]:size' \
|
||||
'-psk_identity[PSK identify when using a PSK cipher suite]:id' \
|
||||
'-psk_hint[PSK identity hint when using a PSK cipher suite]:hint' \
|
||||
'-psk[PSK key when using a PSK cipher suite]:key' \
|
||||
'-psk_session[file contains pem encoded SSL_SESSION data]:file:_files' \
|
||||
'-srpvfile[verifier file for SRP]:file:_files' \
|
||||
'-listen[listen on a UDP port for incoming connections]' \
|
||||
'-sctp[use SCTP for the transport protocol instead of UDP in DTLS]' \
|
||||
'-sctp_label_bug[allow communication with older broken implementations]' \
|
||||
'-use_srtp[offer SRTP key management with a colon-separated profile list]:list' \
|
||||
'-no_dhe[no DH parameters will be loaded]' \
|
||||
'-alpn[enable the Application-Layer Protocol Negotiation extension]:protocol' \
|
||||
'-nextprotoneg[enable the Next Protocol Negotiation extension]:protocol' \
|
||||
'-ktls[enable kernel TLS for sending and receiving]' \
|
||||
'-sendfile[SSL_sendfile will be used instead of BIO_write to send response]' \
|
||||
'-zerocopy_sendfile[SSL_sendfile will use the zerocopy TX mode]' \
|
||||
'-keylogfile[append TLS secrets to the specified keylog file]:file:_files' \
|
||||
'-max_early_data[change the default maximum early data bytes for new sessions and incoming early data]:size' \
|
||||
'-recv_max_early_data[hard limit on the maximum number of early data bytes that will be accepted]:bytes' \
|
||||
'-early_data[accept early data where possible]' \
|
||||
'-stateless[require TLSv1.3 cookies]' \
|
||||
'(-anti_replay -no_anti_replay)-anti_replay[switch replay protection on]' \
|
||||
'(-anti_replay -no_anti_replay)-no_anti_replay[switch replay protection off]' \
|
||||
'-tfo[enable acceptance of TCP fast Open connections]' \
|
||||
'-cert_comp[pre-compresses certificates that will be sent during the handshake]' \
|
||||
'-nameopt[how the subject or issuer names are displayed]:how:_openssl_name_display_options' \
|
||||
$openssl_tls_flags[@] \
|
||||
$openssl_dtls_flags[@] \
|
||||
$openssl_supported_commands_flags[@] \
|
||||
$openssl_extended_verification_flags[@] \
|
||||
$openssl_trusted_certificate_options[@] \
|
||||
$openssl_random_state_options[@] \
|
||||
$openssl_provider_options[@] \
|
||||
$openssl_verification_options[@] \
|
||||
'-enable_server_rpk[enable support for sending raw public keys to the client]' \
|
||||
'-enable_client_rpk[enable support for receiving raw public keys from the client]'
|
||||
}
|
||||
|
||||
_openssl_s_time() {
|
||||
|
|
|
|||
14
src/_scala
14
src/_scala
|
|
@ -208,13 +208,13 @@ _scala() {
|
|||
;;
|
||||
(*)
|
||||
case $service in
|
||||
(scala)
|
||||
_arguments $scala_options $common_options "*::filename:_files" && ret=0
|
||||
;;
|
||||
(scalac)
|
||||
_arguments $common_options "*::filename:_files" && ret=0
|
||||
;;
|
||||
esac
|
||||
(scala)
|
||||
_arguments $scala_options $common_options "*::filename:_files" && ret=0
|
||||
;;
|
||||
(scalac)
|
||||
_arguments $common_options "*::filename:_files" && ret=0
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
|
||||
|
|
|
|||
|
|
@ -121,10 +121,10 @@ _setcap_capabilities() {
|
|||
|
||||
_setcap "$@"
|
||||
|
||||
# Local variables:
|
||||
# Local Variables:
|
||||
# mode: Shell-Script
|
||||
# sh-indentation: 2
|
||||
# indent-tabs-mode: nil
|
||||
# sh-basic-offset: 2
|
||||
# End:
|
||||
# ex: sw=2 ts=2 et filetype=sh
|
||||
# vim: ft=zsh sw=2 ts=2 et
|
||||
|
|
|
|||
|
|
@ -23,3 +23,11 @@ local modes=('up\:"bring a wireguard interface up"'\
|
|||
# 2: Complete interface with all .conf files in /etc/wireguard without the filename extension.
|
||||
_arguments "1:mode:((${modes}))"\
|
||||
'2:interface:_path_files -W /etc/wireguard -g "*.conf(^/:r)"'
|
||||
|
||||
# Local Variables:
|
||||
# mode: Shell-Script
|
||||
# sh-indentation: 2
|
||||
# indent-tabs-mode: nil
|
||||
# sh-basic-offset: 2
|
||||
# End:
|
||||
# vim: ft=zsh sw=2 ts=2 et
|
||||
|
|
|
|||
|
|
@ -0,0 +1,454 @@
|
|||
* 目录
|
||||
- [[#介绍][介绍]]
|
||||
- [[#开始][开始]]
|
||||
- [[#让zsh知道用哪个函数补全命令][让zsh知道用哪个函数补全命令]]
|
||||
- [[#补全gnu格式命令][补全gnu格式命令]]
|
||||
- [[#从其它命令复制补全][从其它命令复制补全]]
|
||||
- [[#编写你自己的补全代码][编写你自己的补全代码]]
|
||||
- [[#工具函数][工具函数]]
|
||||
- [[#用_describe编写简单的补全函数][用_describe编写简单的补全函数]]
|
||||
- [[#用_alternative编写补全函数][用_alternative编写补全函数]]
|
||||
- [[#用_arguments编写补全函数][用_arguments编写补全函数]]
|
||||
- [[#用_regex_arguments和_regex_words编写补全函数][用_regex_arguments和_regex_words编写补全函数]]
|
||||
- [[#用_values_sep_parts和_multi_parts实现复杂补全][用_values、_sep_parts和_multi_parts实现复杂补全]]
|
||||
- [[#用compadd直接添加补全词][用compadd直接添加补全词]]
|
||||
- [[#测试与debug][测试与debug]]
|
||||
- [[#踩坑了吧-需要小心的东西][踩坑了吧 (需要小心的东西)]]
|
||||
- [[#小贴士][小贴士]]
|
||||
- [[#其它资源][其它资源]]
|
||||
|
||||
> 译注:本文可能有不通顺的地方,或者采用的词汇不是很正确。
|
||||
> 如果你有更好的主意,欢迎提交PR。
|
||||
|
||||
* 介绍
|
||||
Zsh官方的补全函数文档令人费解,而且也没提供多少示例。
|
||||
写这份文档的当下我已经在网上找到了其它几份教程,但是那些教程只涉及了补全系统的一小部分。
|
||||
这份文档目的在于补全网上其它地方没涵盖的部分,同时附带示例,这样读者就可以学会如何写更高级的补全函数。
|
||||
我不会展开每一细节,但给你提供的内容和示例足以从零开始。
|
||||
如果你需要了解更多细节,你可以自行查询[[https://zsh.sourceforge.net/Doc/Release/Completion-System.html#Completion-System][官方文档]]。
|
||||
|
||||
还请公开你所创作的任何脚本(比如fork这个仓库然后[[id:64bcd501-b0f0-48c7-b8e2-07af708b95ec][pr]])。
|
||||
此外如果你有任何更多补充内容或对此教程的改进,欢迎做贡献。
|
||||
* 开始
|
||||
** 让zsh知道用哪个函数补全命令
|
||||
补全命令用的补全函数储存于名字以下划线“_”起始的文件,这些文件应存于$fpath变量所列出的某目录中。
|
||||
你可以将下面的代码写入你的~/.zshrc以在$fpath中新增目录:
|
||||
#+BEGIN_SRC sh
|
||||
fpath=(~/newdir $fpath)
|
||||
#+END_SRC
|
||||
一个补全函数文件的第一行长这个样:
|
||||
#+BEGIN_SRC sh
|
||||
#compdef foobar
|
||||
#+END_SRC
|
||||
这行代码表示这个文件含有补全foobar命令的代码。
|
||||
多数情况下第一行都采用这个格式,但你也可以用同一个文件补全多个不同的函数。
|
||||
查阅[[https://zsh.sourceforge.net/Doc/Release/Completion-System.html#Autoloaded-files][官方文档]]以了解更多细节。
|
||||
|
||||
你也可以直接使用compdef命令(比如在你的~/.zshrc文件里)来告诉zsh用哪个函数补全命令:
|
||||
#+BEGIN_SRC sh
|
||||
> compdef _function foobar
|
||||
#+END_SRC
|
||||
或者对多个命令使用同一种补全:
|
||||
#+BEGIN_SRC sh
|
||||
> compdef _function foobar goocar hoodar
|
||||
#+END_SRC
|
||||
如果你想提供参数的话:
|
||||
#+BEGIN_SRC sh
|
||||
> compdef '_function arg1 arg2' foobar
|
||||
#+END_SRC
|
||||
查阅[[https://zsh.sourceforge.net/Doc/Release/Completion-System.html#Functions-4][官方文档]]以了解更多细节。
|
||||
** 补全gnu格式命令
|
||||
很多[[https://www.gnu.org/][gnu]]命令以标准化的方式列出选项描述(使用--help选项时)。
|
||||
对于这些命令你可以使用_gnu_generic函数自动创建补全,比如这样:
|
||||
#+BEGIN_SRC sh
|
||||
> compdef _gnu_generic foobar
|
||||
#+END_SRC
|
||||
或者对多个不同命令使用_gnu_generic:
|
||||
#+BEGIN_SRC sh
|
||||
> compdef _gnu_generic foobar goocar hoodar
|
||||
#+END_SRC
|
||||
你可以把这行代码放进~/.zshrc文件里。
|
||||
** 从其它命令复制补全
|
||||
如果你想要让一个命令(比如cmd1)和另一个已有补全的命令(比如cmd2)拥有相同的补全,你可以:
|
||||
#+BEGIN_SRC sh
|
||||
> compdef cmd1=cmd2
|
||||
#+END_SRC
|
||||
比如当你给一个命令创建了一个助记alias的时候会很有帮助。
|
||||
* 编写你自己的补全代码
|
||||
你可以通过阅读已有的补全函数来开始入门。
|
||||
在我的Linux系统上这些补全函数在/usr/share/zsh/functions/Completion/Unix、
|
||||
/usr/share/zsh/functions/Completion/Linux和一些其它子目录下。
|
||||
|
||||
你会注意到这些文件频繁使用_arguments函数。
|
||||
该函数是一个工具函数,可用于编写简单的补全函数。
|
||||
_arguments函数是一个compadd内置函数的包装函数。
|
||||
compadd内置函数是一个核心函数,用于向命令行加入补全词,并控制其行为。
|
||||
不过,多数情况下你不需要使用compadd,因为有很多更易于使用的工具函数,如_arguments和_describe。
|
||||
|
||||
对于非常基础的补全,_describe函数已经够用了。
|
||||
|
||||
** 工具函数
|
||||
下面是一个工具函数列表,你或许会用到它们。
|
||||
工具函数的完整列表及使用方法在[[https://zsh.sourceforge.net/Doc/Release/Completion-System.html#Completion-Functions][此]]可供查阅。
|
||||
这些函数的使用示例在下一节给出。
|
||||
|
||||
> 译注:从这里开始会出现一些术语,如定义(specification)、描述(description)、动作(action)、词汇(word)等。
|
||||
> 初次阅读可能会觉得比较困难,尤其是下面的工具函数表格,稍后教程开始一一讲解并给出示例的时候就好懂多了。
|
||||
> 定义指的是对补全规则的定义,如`_describe 定义`。
|
||||
> 描述当然指的是对命令行选项和参数的用户友好描述,补全时会显示在屏幕上,如:'-o 输出文件'
|
||||
> 词汇指的是如同'word'、'-o'、'--help'、'start'等连续的一小段字符串
|
||||
> 动作指的是匹配成功后执行的操作,比如执行某函数生成补全,或直接补全等等。
|
||||
> 选项(option)和参数指给命令提供的选项和参数,如`cp -r src dst`中,`-r`为选项,`src`和`dst`为参数。有些选项带参,如`tar -f file ...`中`-f`选项带`file`参数。
|
||||
> 候选(candidate)指可能的补全结果,如补全`tar -f`时目录下所有文件会被作为候选,补全`systemctl`时`start`、`stop`、`list-units`等指令会被作为候选。
|
||||
> 还请不要感到灰心,读下去就是了。
|
||||
|
||||
*** 用于大部分补全的主要工具函数
|
||||
| _alternative | 从其它工具函数或shell代码生成补全候选。 |
|
||||
| _arguments | 指定如何补全一命令的各选项和参数(命令选项风格为unix风格)。 |
|
||||
| _describe | 创建由带描述的词汇(但不包含动作)组成的简单补全。比_arguments更简单。 |
|
||||
| _gnu_generic | 为带有“--help”选项的命令补全选项。 |
|
||||
| _regex_arguments | 创建一先用regex表达式匹配命令行参数再执行动作/补全的函数。 |
|
||||
*** 对单个词汇进行复杂补全的工具函数
|
||||
| _values | 补全任意词汇(值)及其参数,或逗号分隔的词汇与参数列表。 |
|
||||
| _combination | 补全值的组合,比如域名和用户名的二元组。 |
|
||||
| _multi_parts | 对词汇的由符号分隔的多个部分分别补全,比如补全路径:/u/i/sy -> /usr/include/sys |
|
||||
| _sep_parts | 类似_multi_parts但在补全的不同部分中允许不同的分隔符。 |
|
||||
| _sequence | 包装另一补全函数,并补全由该函数生成的匹配列表。 |
|
||||
*** 用于补全特定对象种类的函数
|
||||
| _path_files | 补全文件目录。用多个选项控制行为。 |
|
||||
| _files | 使用所有选项调用_path_files,除了-g和-/。这些选项取决于file-patterns风格设置。 |
|
||||
| _net_interfaces | 补全网络接口名称。 |
|
||||
| _users | 补全用户名 |
|
||||
| _groups | 补全组名 |
|
||||
| _options | 补全shell选项名。 |
|
||||
| _parameters | 补全shell参数/变量名(可用模式匹配限制要补全的参数/变量名)。 |
|
||||
*** 处理已缓存的补全的函数
|
||||
如果你有大量的补全,你可以将补全保存于一个缓存文件以快速加载。
|
||||
| _cache_invalid | 指明补全缓存是否需要重新构建(rebuild),缓存由标识符指定 |
|
||||
| _retrieve_cache | 从缓存文件获取补全信息 |
|
||||
| _store_cache | 储存缓存于缓存文件,缓存由标识符指定 |
|
||||
*** 其它函数
|
||||
| _message | 当无补全可生成时显示帮助信息。 |
|
||||
| _regex_words | 为_regex_arguments命令生成参数。比手写参数更简单。 |
|
||||
| _guard | 检查被补全的词汇,用于_arguments和类似函数的定义的ACTION中。 |
|
||||
*** 动作(Actions)
|
||||
许多工具函数,如_arguments、_regex_arguments、_alternative和_values,在选项/参数末尾有一个action。
|
||||
这个action指定如何补全对应的参数。
|
||||
这些action可以是如下形式之一:
|
||||
| ( ) | 需要提供参数但未生成任何匹配 |
|
||||
| (ITEM1 ITEM2) | 匹配列表 |
|
||||
| ((ITEM1\:'DESC1' ITEM2\:'DESC2')) | 匹配列表,带有描述。引号必须和整个定义所使用的引号不同。 |
|
||||
| ->STRING | 将$state设为STRING然后继续(可在调用工具函数后用case语句检查$state的值) |
|
||||
| FUNCTION | 生成匹配或完成其它操作的函数的函数名,比如_files或_message |
|
||||
| {EVAL-STRING} | 把字符串当作shell代码执行(evaluate)。可用于带参调用工具函数,如_values或_describe |
|
||||
| =ACTION | 在补全命令行中插入占位词汇不改变补全点。 |
|
||||
|
||||
并非所有的action种类都可用于使用action的工具函数。比如->STRING类不可用于_regex_arguments或_alternative函数。
|
||||
** 用_describe编写简单的补全函数
|
||||
_describe函数可以用于简单的补全,此类补全的选项/参数的位置与顺序无关紧要。
|
||||
你只需用一个数组参数储存这些选项和其描述,然后将数组参数的名作为参数传入_describe。
|
||||
下面的示例创建补全候选c和d(注意代码文件名应为_cmd,并且文件存于$fpath所列出的目录之下)。
|
||||
#+BEGIN_SRC sh
|
||||
#compdef cmd
|
||||
local -a subcmds
|
||||
subcmds=('c:c命令描述' 'd:d命令描述')
|
||||
_describe 'command' subcmds
|
||||
#+END_SRC
|
||||
|
||||
你可以像下面一样使用由双横杠分隔的列表,但注意实操时会混合匹配结果,所以不应该用于不同种类的补全候选:
|
||||
#+BEGIN_SRC sh
|
||||
local -a subcmds topics
|
||||
subcmds=('c:c命令描述' 'd:d命令的描述')
|
||||
topics=('e:e帮助主题的描述' 'f:f帮助主题的描述')
|
||||
_describe 'command' subcmds -- topics
|
||||
#+END_SRC
|
||||
|
||||
如果两个候选有相同的描述,_describe把它们集于一行,并确保描述严格按列对齐。
|
||||
_describe函数可用在_alternative、_arguments或_regex_arguments的ACTION中。
|
||||
在这种情况下你需要用括号将_describe和参数包起来,比如'TAG:DESCRIPTION:{_describe 'values' options}'
|
||||
** 用_alternative编写补全函数
|
||||
如同_describe,该函数进行简单补全,其选项/参数的顺序和位置并不重要。
|
||||
然而,与_describe的固定匹配不同,_alternative可进一步调用函数生成补全候选。
|
||||
此外,_alternative允许混合不同种类的补全候选。
|
||||
|
||||
关于参数,该函数接受一列定义(specification),每项定义的形式为“TAG:DESCRIPTION:ACTION”(即“标签:描述:动作”),其中TAG是一个标识补全匹配种类的特殊标签。
|
||||
DESCRIPTION以标题(heading)的形式描述补全候选组,而ACTION是先前列出的动作种类之一(除了->STRING和=ACTION之外)。
|
||||
例如:
|
||||
#+BEGIN_SRC sh
|
||||
_alternative 'arguments:自定义参数:(a b c)' 'files:文件名:_files'
|
||||
#+END_SRC
|
||||
第一个定义增加了补全候选a、b和c,而第二个定义调用_files函数以补全文件目录。
|
||||
|
||||
我们可以用反斜杠 \ 将不同定义分成几行并给每个自定义参数加入描述文字:
|
||||
#+BEGIN_SRC sh
|
||||
_alternative \
|
||||
'args:自定义参数:((a\:"描述a" b\:"描述b" c\:"描述c"))' \
|
||||
'files:文件名:_files'
|
||||
#+END_SRC
|
||||
|
||||
如果我们想向_files传递参数,我们可以直接写在_files后面:
|
||||
#+BEGIN_SRC sh
|
||||
_alternative \
|
||||
'args:自定义参数:((a\:"描述a" b\:"描述b" c\:"描述c"))' \
|
||||
'files:文件名:_files -/'
|
||||
#+END_SRC
|
||||
|
||||
如要用变量展开创建补全列表,必须用双引号将定义括起来,
|
||||
如:
|
||||
#+BEGIN_SRC sh
|
||||
_alternative \
|
||||
"dirs:用户目录:($userdirs)" \
|
||||
"pids:进程ID:($(ps -A o pid=))"
|
||||
#+END_SRC
|
||||
在此例子中第一个定义加入$userdirs变量中的词汇,第二个定义执行'ps -A o pid='并获取pid表,pid表用作补全候选。
|
||||
实操中,我们使用已有的_pids函数,而不是像上面那样手写。
|
||||
|
||||
我们可以在ACTION中使用_values等其它工具函数以完成更复杂的补全,如:
|
||||
#+BEGIN_SRC sh
|
||||
_alternative \
|
||||
"directories:用户目录:($userdirs)" \
|
||||
'options:逗号分隔选项: _values -s , letter a b c'
|
||||
#+END_SRC
|
||||
该示例补全$userdirs里的项目,以及用逗号分隔的、含有a、b和/或c的列表。
|
||||
注意_values前面的空格。空格不可省略,因为_values不能接受标准compadd描述选项。
|
||||
|
||||
和_describe一样,_alternative可用作ACTION并作为_arguments或_regex_arguments的一部分。
|
||||
** 用_arguments编写补全函数
|
||||
只需要调用_arguments函数一次就可以创造出非常智能的补全函数。该函数本身就是用于处理这种带有带参选项的命令的。
|
||||
如同_alternative函数,_arguments接受一列定义字符串参数。
|
||||
这些定义字符串指定选项和任何对应的选项参数(如:-f 文件名),或命令参数。
|
||||
|
||||
简单的选项定义用'-OPT[DESCRIPTION]'(即'-选项[描述]'),比如:
|
||||
#+BEGIN_SRC sh
|
||||
_arguments '-s[排序后输出]' '--l[更多输出]' '-l[更多输出]'
|
||||
#+END_SRC
|
||||
选项参数可在选项描述后指定,形式用'-OPT[DESCRIPTION]:MESSAGE:ACTION'(即'-选项[描述]:消息:动作'),
|
||||
其中MESSAGE是待显示的信息,而ACTION可以是前面的动作(Actions)章节提到的任何形式。
|
||||
比如:
|
||||
#+BEGIN_SRC sh
|
||||
_arguments '-f[输入文件]:文件名:_files'
|
||||
#+END_SRC
|
||||
|
||||
命令参数定义用'N:MESSAGE:ACTION'(即'N:消息:动作'),其中N指定这是第N个命令参数,而MESSAGE和ACTION都和前面的一样。
|
||||
如果N被省略,则其仅表示这是(在所有已定义的参数之后的)下一个参数。如果开头(在N后面)用的是双冒号,则参数非必需。
|
||||
比如:
|
||||
#+BEGIN_SRC sh
|
||||
_arguments '-s[排序后输出]' '1:第一个参数:_net_interfaces' '::可选参数:_files' ':下一个参数:(a b c)'
|
||||
#+END_SRC
|
||||
这里第一个参数是网络接口,下一个可选参数是一个文件名,最后一个参数可以是a、b或c,而-s选项可以在任何位置被补全。
|
||||
|
||||
_arguments函数允许所有ACTION形式(在前面的动作(Actions)章节列出)。
|
||||
这表示你可以用动作来选择case语句分支,如:
|
||||
#+BEGIN_SRC sh
|
||||
_arguments '-m[音乐文件]:文件名:->files' '-f[flags]:flag:->flags'
|
||||
case "$state" in
|
||||
files)
|
||||
local -a music_files
|
||||
music_files=( Music/**/*.{mp3,wav,flac,ogg} )
|
||||
_multi_parts / music_files
|
||||
;;
|
||||
flags)
|
||||
_values -s , 'flags' a b c d e
|
||||
;;
|
||||
esac
|
||||
#+END_SRC
|
||||
在此例子中指向音乐文件的路径被_multi_parts一步步地沿目录下降补全,
|
||||
而flags被_values函数按照逗号分隔列表补全。
|
||||
|
||||
我已经介绍了_arguments定义的基础部分,你还可以定义互斥选项、重复选项和参数、以+开头的选项等。有关更多细节,查阅[[https://zsh.sourceforge.net/Doc/Release/Completion-System.html#Completion-System][官方文档]]。
|
||||
同时你也可以看看本文末尾列出的教程,以及[[https://github.com/vapniks/zsh-completions/tree/master/src][src目录]]下的补全函数。
|
||||
** 用_regex_arguments和_regex_words编写补全函数
|
||||
如果你的命令行定义比较复杂,有多个可能的参数序列,那你可能需要_regex_arguments函数。
|
||||
该函数也适用于有一系列跟着多个参数的关键词的情况。
|
||||
|
||||
_regex_arguments创建名字由第一个参数给出的补全函数。
|
||||
因此你需要先调用_regex_arguments来创建补全函数,然后再调用该函数,比如:
|
||||
#+BEGIN_SRC sh
|
||||
_regex_arguments _cmd OTHER_ARGS..
|
||||
_cmd "$@"
|
||||
#+END_SRC
|
||||
|
||||
OTHER_ARGS(即“其它参数”)是一序列用于在命令行上匹配和补全词汇的定义。
|
||||
这些序列可被'|'分隔来表示备选词汇序列。
|
||||
你可以用任意嵌套深度的括号来指定备选序列,但括号必须带反斜杠前缀,如\( \),或用引号括起来,如'(' ')'。
|
||||
|
||||
比如:
|
||||
#+BEGIN_SRC sh
|
||||
_regex_arguments _cmd 序列1 '|' 序列2 \( 序列2a '|' 序列2b \)
|
||||
_cmd "$@"
|
||||
#+END_SRC
|
||||
该示例定义一个匹配序列1或序列2后跟着序列2a或序列2b的命令行。这种方式和正则表达式语法类似。
|
||||
|
||||
一个序列中的每个定义必须在开头包含一个/ PATTERN/ (即/ 模式/)部分,后跟着可选的':TAG:DESCRIPTION:ACTION'(即':标签:描述:动作')部分。
|
||||
|
||||
每个PATTERN是一个匹配一命令行词汇的正则表达式。这些模式按顺序匹配,直到某个模式不匹配,不匹配的模式将执行对应的ACTION(动作)以进行补全。
|
||||
注意,一定要有一个匹配命令自身的模式。
|
||||
下面有对PATTERN(模式)更详细的解释。
|
||||
|
||||
':TAG:DESCRIPTION:ACTION'的使用方法和_alternative相同,只是开头多了个冒号“:”,并且前面列出的所有ACTION格式都可用。
|
||||
|
||||
例如:
|
||||
#+BEGIN_SRC sh
|
||||
_regex_arguments _cmd /$'[^\0]##\0'/ \( /$'word1(a|b|c)\0'/ ':word:first word:(word1a word1b word1c)' '|'\
|
||||
/$'word11(a|b|c)\0'/ ':word:first word:(word11a word11b word11c)' \( /$'word2(a|b|c)\0'/ ':word:second word:(word2a word2b word2c)'\
|
||||
'|' /$'word22(a|b|c)\0'/ ':word:second word:(word22a word22b word22c)' \) \)
|
||||
_cmd "$@"
|
||||
#+END_SRC
|
||||
TODO 英文原文和例子有出入
|
||||
|
||||
在这个例子中第一个词可以是word1(即“词1”,下同)或者word11后紧跟a、b或c,并且如果第一个词含有11,则第二个词可以是word2后紧跟a、b或c,或一个文件名。
|
||||
|
||||
如果感觉太复杂,你也可以用更简单的_regex_words函数达到相同效果。
|
||||
*** 模式
|
||||
你可能注意到了上个例子中的/ PATTERN/和普通的正则表达式不太一样。
|
||||
通常使用的是形如$'foo\0'的字符串参数。这是为了让\0表示成null字符,而zsh内部用来分隔词汇的也是null字符。
|
||||
如果不在末尾包含\0的话,可能会无法匹配下一个词。如果你要把一个变量的值作为模式的一部分,你可以用双括号包起来,
|
||||
这样变量就会展开,然后再在后面加个包含null字符的字符串参数,比如:"$somevar"$'\0'(somevar即“某变量”)。
|
||||
|
||||
表示模式用的正则表达式语法和正常的正则表达式不太一样,但我也找不到有关的文档。
|
||||
不过我还是试图搞清楚了这些特殊字符的意义:
|
||||
| * | 通配符 - 任何数量的字符 |
|
||||
| ? | 通配符 - 单个字符 |
|
||||
| # | 零个或更多的上一个字符(和一般正则表达式里的*一样) |
|
||||
| ## | 一个或更多的上一个字符(和一般正则表达式里的+一样) |
|
||||
*** _regex_words
|
||||
_regex_words函数比_regex_arguments更简单易用。
|
||||
调用_regex_words后的结果可以存在变量里。
|
||||
|
||||
要用_regex_words创建一个定义(specification),你需要提供一个标签,后跟一段描述,后跟一个定义不同词汇的列表。
|
||||
这些定义采用'WORD:DESCRIPTION:SPEC'(即'词汇:描述:定义')的格式,WORD即待补全的词,DESCRIPTION是对应的描述,
|
||||
SPEC可以是由_regex_words创建的另一个变量以指定当前词后的下一个词汇,也可以留空以表示没有更多的词。
|
||||
比如:
|
||||
#+BEGIN_SRC sh
|
||||
_regex_words firstword '第一个词' 'word1a:词a:' 'word1b:词b:' 'word1c:词c'
|
||||
#+END_SRC
|
||||
该函数的返回结果将被存入$reply(reply即“回复”、“回应”)数组里,所以我们需要在$reply变化前将结果存进另一个数组里,如:
|
||||
#+BEGIN_SRC sh
|
||||
local -a firstword
|
||||
_regex_words word 'The first word' 'word1a:a word:' 'word1b:b word:' 'word1c:c word'
|
||||
firstword="$reply[@]"
|
||||
#+END_SRC
|
||||
firstword即“第一个词”。
|
||||
然后我们可以把结果用在_regex_arguments里,如:
|
||||
#+BEGIN_SRC sh
|
||||
_regex_arguments _cmd /$'[^\0]##\0'/ "$firstword[@]"
|
||||
_cmd "$@"
|
||||
#+END_SRC
|
||||
注意到我给命令自身也加了模式。
|
||||
|
||||
这里还有个更复杂的词汇,我们调用_regex_words以匹配不同词汇
|
||||
#+BEGIN_SRC sh
|
||||
local -a firstword firstword2 secondword secondword2
|
||||
_regex_words word1 '第二个词' 'woo:鄧族' 'hoo:不关我事'
|
||||
secondword=("$reply[@]")
|
||||
_regex_words word2 '另一个第二个词' 'yee:汝' 'haa:很搞笑!'
|
||||
secondword2=("$reply[@]")
|
||||
_regex_words commands '第一个词' 'foo:做foo' 'man:yeah man' 'chu:at chu' # 译注:作者在自嗨,at chu除了比较像at you外没什么特殊意义
|
||||
firstword=("$reply[@]")
|
||||
_regex_words word4 '另一个第一个词' 'boo:吓死某人:$secondword' 'ga:嘤嘤嘤:$secondword'\
|
||||
'loo:上厕所:$secondword2'
|
||||
firstword2=("$reply[@]")
|
||||
|
||||
_regex_arguments _hello /$'[^\0]##\0'/ "${firstword[@]}" "${firstword2[@]}"
|
||||
_hello "$@"
|
||||
#+END_SRC
|
||||
在这个例子中第一个词可以是"foo"、"man"、"chu"、"boo"、"ga"或"loo"。
|
||||
如果第一个词是"boo"或"ga",那下一个词可以是"woo"或"hoo",
|
||||
而如果第一个词是"loo"则第二个词可以是"yee"或"haa",其它情况下没有第二个词。
|
||||
|
||||
_ip函数是_regex_words的一个好用例。
|
||||
** 用_values、_sep_parts和_multi_parts实现复杂补全
|
||||
_values、_sep_parts和_multi_parts可以单独使用,也可以作为_alternative、_arguments或_regex_arguments定义里的ACTION。可以看看下面的例子。
|
||||
查阅[[https://zsh.sourceforge.net/Doc/Release/Completion-System.html#Completion-System][官方文档]]以了解更多信息。
|
||||
|
||||
空格分隔的mp3文件列表:
|
||||
#+BEGIN_SRC sh
|
||||
_values 'mp3文件' ~/*.mp3
|
||||
#+END_SRC
|
||||
|
||||
逗号分隔的会话id列表:
|
||||
#+BEGIN_SRC sh
|
||||
_values -s , '会话id' "${(uonzf)$(ps -A o sid=)}"
|
||||
#+END_SRC
|
||||
|
||||
补全foo@news:woo、foo@news:laa或bar@news:woo等:
|
||||
#+BEGIN_SRC sh
|
||||
_sep_parts '(foo bar)' @ '(news ftp)' : '(woo laa)'
|
||||
#+END_SRC
|
||||
|
||||
补全MAC地址,一次补全一个字节:
|
||||
#+BEGIN_SRC sh
|
||||
_multi_parts : '(00:11:22:33:44:55 00:23:34:45:56:67 00:23:45:56:67:78)'
|
||||
#+END_SRC
|
||||
|
||||
** 用compadd直接添加补全词
|
||||
你可以使用内置的compadd函数增加补全词,以获得更细致的控制。
|
||||
这个函数有各种选项控制如何显示补全以及补全时如何替换命令行上的文字。
|
||||
阅读[[https://zsh.sourceforge.net/Doc/Release/Completion-System.html#Completion-System][官方文档]]以获得更多细节。
|
||||
这里我只给出几个简单的示例。
|
||||
|
||||
向补全列表里加入若干词汇:
|
||||
#+BEGIN_SRC sh
|
||||
compadd foo bar blah
|
||||
#+END_SRC
|
||||
|
||||
同上但显示注释:
|
||||
#+BEGIN_SRC sh
|
||||
compadd -X '一些注释' foo bar blah
|
||||
#+END_SRC
|
||||
|
||||
同上但在补全前自动插入"what_"前缀
|
||||
#+BEGIN_SRC sh
|
||||
compadd -P what_ foo bar blah
|
||||
#+END_SRC
|
||||
|
||||
同上但补全后自动插入"_todo"后缀:
|
||||
#+BEGIN_SRC sh
|
||||
compadd -S _todo foo bar blah
|
||||
#+END_SRC
|
||||
|
||||
同上但在后缀后打空格时自动移除"_todo"后缀:
|
||||
#+BEGIN_SRC sh
|
||||
compadd -P _todo -q foo bar blah
|
||||
#+END_SRC
|
||||
|
||||
向补全数组$wordsarray(wordsarray即“词数组”)加入词汇
|
||||
#+BEGIN_SRC sh
|
||||
compadd -a wordsarray
|
||||
#+END_SRC
|
||||
|
||||
* 测试与debug
|
||||
重新加载补全函数:
|
||||
#+BEGIN_SRC sh
|
||||
> unfunction _func
|
||||
> autoload -U _func
|
||||
#+END_SRC
|
||||
|
||||
这些函数会提供有用的信息。
|
||||
如果默认按键没有用,你可以尝试Alt+x然后再输入命令名。
|
||||
| 函数 | 默认按键 | 作用 |
|
||||
|-----------------+--------------------+----------------------------------------------------------------|
|
||||
| _complete_help | Ctrl+x h | 在当前光标位置补全时显示有关上下文名称、标签和补全函数的信息 |
|
||||
| _complete_help | Alt+2 Ctrl+x h | 同上但显示更多信息 |
|
||||
| _complete_debug | Ctrl+x ? | 执行正常补全,但跟踪补全系统执行的shell命令并存入一个临时文件 |
|
||||
* 踩坑了吧 (需要小心的东西)
|
||||
记得在补全函数的文件开头加那行#compdef
|
||||
|
||||
_arguments或_regex_arguments的定义中要使用正确的引号:
|
||||
如果定义中有变量要展开,用双引号,其它情况用单引号,
|
||||
并且记得在ITEM(项目)描述处用不同的引号。(译注:见[[#动作Actions][动作(Actions)]]章节)
|
||||
|
||||
_arguments、_alternative、_regex_arguments等的定义处要在正确的地方使用正确数量的冒号“:”。
|
||||
|
||||
使用_regex_arguments时要记得在开头写匹配命令的模式(不需要加入匹配动作(action))。
|
||||
|
||||
记得在_regex_arguments的任何PATTERN(模式)参数后加上null字符$'\0'
|
||||
* 小贴士
|
||||
有时一个子命令后只会跟一个选项,这时zsh会在tab在子命令后按下时自动补全。如果你想要在补全前先列出选项和描述,
|
||||
你可以向ACTION(动作)加入另一个空选项(比如\:),如':TAG:DESCRIPTION:((opt1\:"opt1描述" \:))'
|
||||
注意这只对在定义参数中使用ACTION的工具函数(_arguments、_regex_arguments等)有效。
|
||||
|
||||
* 其它资源
|
||||
[[https://wikimatze.de/writing-zsh-completion-for-padrino/][这]]是个展示_arguments函数的基本使用方法的教程,短小精悍,
|
||||
而[[https://web.archive.org/web/20190411104837/http://www.linux-mag.com/id/1106/][这]]是_arguments函数的稍稍更进阶的教程。
|
||||
[[https://zsh.sourceforge.net/Doc/Release/Completion-System.html#Completion-System][这]]是zshcompsys手册页(man page)。
|
||||
Loading…
Reference in New Issue