Use spaces instead of tabs
This commit is contained in:
parent
28c5bdcaf8
commit
32210c83c5
|
|
@ -108,8 +108,8 @@ _chromium_proxyurls () {
|
||||||
do
|
do
|
||||||
while _next_label prefixes expl 'URL prefix' -S '' "$@"
|
while _next_label prefixes expl 'URL prefix' -S '' "$@"
|
||||||
do
|
do
|
||||||
compset -S '[^:/]*' && compstate[to_end]=''
|
compset -S '[^:/]*' && compstate[to_end]=''
|
||||||
compadd "$expl[@]" http:// socks:// socks4:// socks5:// && ret=0
|
compadd "$expl[@]" http:// socks:// socks4:// socks5:// && ret=0
|
||||||
done
|
done
|
||||||
(( ret )) || return 0
|
(( ret )) || return 0
|
||||||
done
|
done
|
||||||
|
|
@ -123,27 +123,27 @@ _chromium_proxyurls () {
|
||||||
return
|
return
|
||||||
fi ;;
|
fi ;;
|
||||||
(file) [[ -prefix //(127.0.0.1|localhost)/ ]] && compset -P '//(127.0.0.1|localhost)'
|
(file) [[ -prefix //(127.0.0.1|localhost)/ ]] && compset -P '//(127.0.0.1|localhost)'
|
||||||
[[ -prefix /// ]] && compset -P //
|
[[ -prefix /// ]] && compset -P //
|
||||||
if ! compset -P //
|
if ! compset -P //
|
||||||
then
|
then
|
||||||
_tags -C file files
|
_tags -C file files
|
||||||
while _tags
|
while _tags
|
||||||
do
|
do
|
||||||
while _next_label files expl 'local file'
|
while _next_label files expl 'local file'
|
||||||
do
|
do
|
||||||
if [[ -prefix / ]]
|
if [[ -prefix / ]]
|
||||||
then
|
then
|
||||||
_path_files "$expl[@]" -S '' "${glob[@]}" && ret=0
|
_path_files "$expl[@]" -S '' "${glob[@]}" && ret=0
|
||||||
_path_files "$expl[@]" -S/ -r '/' -/ && ret=0
|
_path_files "$expl[@]" -S/ -r '/' -/ && ret=0
|
||||||
elif [[ -z "$PREFIX" ]]
|
elif [[ -z "$PREFIX" ]]
|
||||||
then
|
then
|
||||||
compadd -S '/' -r '/' "$expl[@]" "$@" - "${PWD%/}" && ret=0
|
compadd -S '/' -r '/' "$expl[@]" "$@" - "${PWD%/}" && ret=0
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
(( ret )) || return 0
|
(( ret )) || return 0
|
||||||
done
|
done
|
||||||
return 1
|
return 1
|
||||||
fi ;;
|
fi ;;
|
||||||
esac
|
esac
|
||||||
if ! compset -P '(#b)([^:/]#)([:/])'
|
if ! compset -P '(#b)([^:/]#)([:/])'
|
||||||
then
|
then
|
||||||
|
|
@ -153,10 +153,10 @@ _chromium_proxyurls () {
|
||||||
do
|
do
|
||||||
while _next_label hosts expl host
|
while _next_label hosts expl host
|
||||||
do
|
do
|
||||||
compset -S '[:/]*' || suf="/"
|
compset -S '[:/]*' || suf="/"
|
||||||
(( $#uhosts )) || _hosts -S "$suf" -r '/:' "$expl[@]" && ret=0
|
(( $#uhosts )) || _hosts -S "$suf" -r '/:' "$expl[@]" && ret=0
|
||||||
[[ "$scheme" = http ]] && uhosts=($uhosts $localhttp_servername)
|
[[ "$scheme" = http ]] && uhosts=($uhosts $localhttp_servername)
|
||||||
compadd -S "$suf" -r '/:' "$expl[@]" -a uhosts && ret=0
|
compadd -S "$suf" -r '/:' "$expl[@]" -a uhosts && ret=0
|
||||||
done
|
done
|
||||||
(( ret )) || return 0
|
(( ret )) || return 0
|
||||||
done
|
done
|
||||||
|
|
@ -171,28 +171,28 @@ _chromium_proxyurls () {
|
||||||
then
|
then
|
||||||
if ! compset -P '(#b)([^/]#)/'
|
if ! compset -P '(#b)([^/]#)/'
|
||||||
then
|
then
|
||||||
_users -S/ "$@"
|
_users -S/ "$@"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
user="$match[1]"
|
user="$match[1]"
|
||||||
while _tags
|
while _tags
|
||||||
do
|
do
|
||||||
while _next_label files expl 'local file'
|
while _next_label files expl 'local file'
|
||||||
do
|
do
|
||||||
_path_files "$expl[@]" "$@" -W ~$user/$localhttp_userdir "${glob[@]}" && ret=0
|
_path_files "$expl[@]" "$@" -W ~$user/$localhttp_userdir "${glob[@]}" && ret=0
|
||||||
_path_files -S/ -r '/' "$expl[@]" -W ~$user/$localhttp_userdir-/ && ret=0
|
_path_files -S/ -r '/' "$expl[@]" -W ~$user/$localhttp_userdir-/ && ret=0
|
||||||
done
|
done
|
||||||
(( ret )) || return 0
|
(( ret )) || return 0
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
while _tags
|
while _tags
|
||||||
do
|
do
|
||||||
while _next_label files expl 'local file'
|
while _next_label files expl 'local file'
|
||||||
do
|
do
|
||||||
_path_files "$expl[@]" "$@" -W $localhttp_documentroot "${glob[@]}" && ret=0
|
_path_files "$expl[@]" "$@" -W $localhttp_documentroot "${glob[@]}" && ret=0
|
||||||
_path_files -S/ -r '/' "$expl[@]" -W $localhttp_documentroot -/ && ret=0
|
_path_files -S/ -r '/' "$expl[@]" -W $localhttp_documentroot -/ && ret=0
|
||||||
done
|
done
|
||||||
(( ret )) || return 0
|
(( ret )) || return 0
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
|
|
@ -200,8 +200,8 @@ _chromium_proxyurls () {
|
||||||
do
|
do
|
||||||
(( $#urls )) && while _next_label files expl 'local file'
|
(( $#urls )) && while _next_label files expl 'local file'
|
||||||
do
|
do
|
||||||
_path_files "$expl[@]" "$@" -W $urls/$scheme/$host "${glob[@]}" && ret=0
|
_path_files "$expl[@]" "$@" -W $urls/$scheme/$host "${glob[@]}" && ret=0
|
||||||
_path_files -S/ -r '/' "$expl[@]" -W $urls/$scheme/$host -/ && ret=0
|
_path_files -S/ -r '/' "$expl[@]" -W $urls/$scheme/$host -/ && ret=0
|
||||||
done
|
done
|
||||||
[[ $scheme = (scp|sftp) ]] && _requested remote-files && _remote_files -h $host -- ssh && ret=0
|
[[ $scheme = (scp|sftp) ]] && _requested remote-files && _remote_files -h $host -- ssh && ret=0
|
||||||
(( ret )) || return 0
|
(( ret )) || return 0
|
||||||
|
|
|
||||||
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 ()
|
_arguments -C \
|
||||||
{
|
':command:->command' \
|
||||||
local curcontext="$curcontext" state line
|
'*::options:->options'
|
||||||
typeset -A opt_args
|
|
||||||
|
|
||||||
_arguments -C \
|
case $state in
|
||||||
':command:->command' \
|
(command)
|
||||||
'*::options:->options'
|
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
|
(options)
|
||||||
(command)
|
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
|
esac
|
||||||
subcommands=(
|
;;
|
||||||
'init:Initialize a new git repo with support for the branching model.'
|
esac
|
||||||
'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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
__git-flow-release ()
|
__git-flow-release () {
|
||||||
{
|
local curcontext="$curcontext" state line
|
||||||
local curcontext="$curcontext" state line
|
typeset -A opt_args
|
||||||
typeset -A opt_args
|
|
||||||
|
|
||||||
_arguments -C \
|
_arguments -C \
|
||||||
':command:->command' \
|
':command:->command' \
|
||||||
'*::options:->options'
|
'*::options:->options'
|
||||||
|
|
||||||
case $state in
|
case $state in
|
||||||
(command)
|
(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
|
(options)
|
||||||
subcommands=(
|
case $line[1] in
|
||||||
'start:Start a new release branch.'
|
(start)
|
||||||
'finish:Finish a release branch.'
|
_arguments \
|
||||||
'list:List all your release branches. (Alias to `git flow release`)'
|
-F'[Fetch from origin before performing finish]'\
|
||||||
'publish:Publish this release branch to origin.`)'
|
':version:__git_flow_version_list'
|
||||||
'track:Track a release branch from origin.`)'
|
;;
|
||||||
)
|
(finish)
|
||||||
_describe -t commands 'git flow release' subcommands
|
_arguments \
|
||||||
_arguments \
|
-F'[Fetch from origin before performing finish]' \
|
||||||
-v'[Verbose (more) output]'
|
-s'[Sign the release tag cryptographically]'\
|
||||||
;;
|
-u'[Use the given GPG-key for the digital signature (implies -s)]'\
|
||||||
|
-m'[Use the given tag message]'\
|
||||||
(options)
|
-n'[Don'\''t tag this release]'\
|
||||||
case $line[1] in
|
-p'[Push to $ORIGIN after performing finish]'\
|
||||||
|
-k'[Keep branch after performing finish]'\
|
||||||
(start)
|
':version:__git_flow_version_list'
|
||||||
_arguments \
|
;;
|
||||||
-F'[Fetch from origin before performing finish]'\
|
(publish)
|
||||||
':version:__git_flow_version_list'
|
_arguments \
|
||||||
;;
|
':version:__git_flow_version_list'
|
||||||
|
;;
|
||||||
(finish)
|
(track)
|
||||||
_arguments \
|
_arguments \
|
||||||
-F'[Fetch from origin before performing finish]' \
|
':version:__git_flow_version_list'
|
||||||
-s'[Sign the release tag cryptographically]'\
|
;;
|
||||||
-u'[Use the given GPG-key for the digital signature (implies -s)]'\
|
*)
|
||||||
-m'[Use the given tag message]'\
|
_arguments \
|
||||||
-n'[Don'\''t tag this release]'\
|
-v'[Verbose (more) output]'
|
||||||
-p'[Push to $ORIGIN after performing finish]'\
|
;;
|
||||||
-k'[Keep branch after performing finish]'\
|
esac
|
||||||
':version:__git_flow_version_list'
|
;;
|
||||||
;;
|
esac
|
||||||
|
|
||||||
(publish)
|
|
||||||
_arguments \
|
|
||||||
':version:__git_flow_version_list'
|
|
||||||
;;
|
|
||||||
|
|
||||||
(track)
|
|
||||||
_arguments \
|
|
||||||
':version:__git_flow_version_list'
|
|
||||||
;;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
*)
|
|
||||||
_arguments \
|
|
||||||
-v'[Verbose (more) output]'
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
}
|
||||||
|
|
||||||
__git-flow-hotfix ()
|
__git-flow-hotfix () {
|
||||||
{
|
local curcontext="$curcontext" state line
|
||||||
local curcontext="$curcontext" state line
|
typeset -A opt_args
|
||||||
typeset -A opt_args
|
|
||||||
|
|
||||||
_arguments -C \
|
_arguments -C \
|
||||||
':command:->command' \
|
':command:->command' \
|
||||||
'*::options:->options'
|
'*::options:->options'
|
||||||
|
|
||||||
case $state in
|
case $state in
|
||||||
(command)
|
(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
|
(options)
|
||||||
subcommands=(
|
case $line[1] in
|
||||||
'start:Start a new hotfix branch.'
|
(start)
|
||||||
'finish:Finish a hotfix branch.'
|
_arguments \
|
||||||
'list:List all your hotfix branches. (Alias to `git flow hotfix`)'
|
-F'[Fetch from origin before performing finish]'\
|
||||||
'publish:Publish this hotfix branch to origin`)'
|
':hotfix:__git_flow_version_list'\
|
||||||
)
|
':branch-name:__git_branch_names'
|
||||||
_describe -t commands 'git flow hotfix' subcommands
|
;;
|
||||||
_arguments \
|
|
||||||
-v'[Verbose (more) output]'
|
|
||||||
;;
|
|
||||||
|
|
||||||
(options)
|
(finish)
|
||||||
case $line[1] in
|
_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)
|
(publish)
|
||||||
_arguments \
|
_arguments \
|
||||||
-F'[Fetch from origin before performing finish]'\
|
':hotfix:__git_flow_hotfix_list'
|
||||||
':hotfix:__git_flow_version_list'\
|
;;
|
||||||
':branch-name:__git_branch_names'
|
|
||||||
;;
|
|
||||||
|
|
||||||
(finish)
|
*)
|
||||||
_arguments \
|
_arguments \
|
||||||
-F'[Fetch from origin before performing finish]' \
|
-v'[Verbose (more) output]'
|
||||||
-s'[Sign the release tag cryptographically]'\
|
;;
|
||||||
-u'[Use the given GPG-key for the digital signature (implies -s)]'\
|
esac
|
||||||
-m'[Use the given tag message]'\
|
;;
|
||||||
-p'[Push to $ORIGIN after performing finish]'\
|
esac
|
||||||
':hotfix:__git_flow_hotfix_list'
|
|
||||||
;;
|
|
||||||
|
|
||||||
(publish)
|
|
||||||
_arguments \
|
|
||||||
':hotfix:__git_flow_hotfix_list'
|
|
||||||
;;
|
|
||||||
|
|
||||||
*)
|
|
||||||
_arguments \
|
|
||||||
-v'[Verbose (more) output]'
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
}
|
||||||
|
|
||||||
__git-flow-feature ()
|
__git-flow-feature () {
|
||||||
{
|
local curcontext="$curcontext" state line
|
||||||
local curcontext="$curcontext" state line
|
typeset -A opt_args
|
||||||
typeset -A opt_args
|
|
||||||
|
|
||||||
_arguments -C \
|
_arguments -C \
|
||||||
':command:->command' \
|
':command:->command' \
|
||||||
'*::options:->options'
|
'*::options:->options'
|
||||||
|
|
||||||
case $state in
|
case $state in
|
||||||
(command)
|
(command)
|
||||||
|
local -a subcommands
|
||||||
local -a subcommands
|
subcommands=(
|
||||||
subcommands=(
|
'start:Start a new feature branch.'
|
||||||
'start:Start a new feature branch.'
|
'finish:Finish a feature branch.'
|
||||||
'finish:Finish a feature branch.'
|
'list:List all your feature branches. (Alias to `git flow feature`)'
|
||||||
'list:List all your feature branches. (Alias to `git flow feature`)'
|
'publish:Publish this feature branch to origin.'
|
||||||
'publish:Publish this feature branch to origin.'
|
'track:Track a feature branch from origin.'
|
||||||
'track:Track a feature branch from origin.'
|
'diff:Show a diff of changes since this feature branched off.'
|
||||||
'diff:Show a diff of changes since this feature branched off.'
|
'rebase:Rebase a feature branch on top of develop.'
|
||||||
'rebase:Rebase a feature branch on top of develop.'
|
|
||||||
'checkout:Check out (switch to) the given feature branch.'
|
'checkout:Check out (switch to) the given feature branch.'
|
||||||
'pull:Pull a feature branch from a remote peer.'
|
'pull:Pull a feature branch from a remote peer.'
|
||||||
)
|
)
|
||||||
_describe -t commands 'git flow feature' subcommands
|
_describe -t commands 'git flow feature' subcommands
|
||||||
_arguments \
|
_arguments \
|
||||||
-v'[Verbose (more) output]'
|
-v'[Verbose (more) output]'
|
||||||
;;
|
;;
|
||||||
|
|
||||||
(options)
|
(options)
|
||||||
case $line[1] in
|
case $line[1] in
|
||||||
|
(start)
|
||||||
|
_arguments \
|
||||||
|
-F'[Fetch from origin before performing finish]'\
|
||||||
|
':feature:__git_flow_feature_list'\
|
||||||
|
':branch-name:__git_branch_names'
|
||||||
|
;;
|
||||||
|
|
||||||
(start)
|
(finish)
|
||||||
_arguments \
|
_arguments \
|
||||||
-F'[Fetch from origin before performing finish]'\
|
-F'[Fetch from origin before performing finish]' \
|
||||||
':feature:__git_flow_feature_list'\
|
-r'[Finish branch by rebasing first]'\
|
||||||
':branch-name:__git_branch_names'
|
-k'[Keep branch after performing finish]'\
|
||||||
;;
|
-D'[Force delete feature branch after finish]'\
|
||||||
|
':feature:__git_flow_feature_list'
|
||||||
|
;;
|
||||||
|
|
||||||
(finish)
|
(publish)
|
||||||
_arguments \
|
_arguments \
|
||||||
-F'[Fetch from origin before performing finish]' \
|
':feature:__git_flow_feature_list'\
|
||||||
-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)
|
(track)
|
||||||
_arguments \
|
_arguments \
|
||||||
':feature:__git_flow_feature_list'\
|
':feature:__git_flow_feature_list'\
|
||||||
;;
|
;;
|
||||||
|
|
||||||
(track)
|
(diff)
|
||||||
_arguments \
|
_arguments \
|
||||||
':feature:__git_flow_feature_list'\
|
':branch:__git_branch_names'\
|
||||||
;;
|
;;
|
||||||
|
|
||||||
(diff)
|
(rebase)
|
||||||
_arguments \
|
_arguments \
|
||||||
':branch:__git_branch_names'\
|
-i'[Do an interactive rebase]' \
|
||||||
;;
|
':branch:__git_branch_names'
|
||||||
|
;;
|
||||||
|
|
||||||
(rebase)
|
(checkout)
|
||||||
_arguments \
|
_arguments \
|
||||||
-i'[Do an interactive rebase]' \
|
':branch:__git_flow_feature_list'\
|
||||||
':branch:__git_branch_names'
|
;;
|
||||||
;;
|
|
||||||
|
|
||||||
(checkout)
|
(pull)
|
||||||
_arguments \
|
_arguments \
|
||||||
':branch:__git_flow_feature_list'\
|
':remote:__git_remotes'\
|
||||||
;;
|
':branch:__git_branch_names'
|
||||||
|
;;
|
||||||
|
|
||||||
(pull)
|
*)
|
||||||
_arguments \
|
_arguments \
|
||||||
':remote:__git_remotes'\
|
-v'[Verbose (more) output]'
|
||||||
':branch:__git_branch_names'
|
;;
|
||||||
;;
|
esac
|
||||||
|
;;
|
||||||
*)
|
esac
|
||||||
_arguments \
|
|
||||||
-v'[Verbose (more) output]'
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
}
|
||||||
|
|
||||||
__git-flow-support ()
|
__git-flow-support () {
|
||||||
{
|
local curcontext="$curcontext" state line
|
||||||
local curcontext="$curcontext" state line
|
typeset -A opt_args
|
||||||
typeset -A opt_args
|
|
||||||
|
|
||||||
_arguments -C \
|
_arguments -C \
|
||||||
':command:->command' \
|
':command:->command' \
|
||||||
'*::options:->options'
|
'*::options:->options'
|
||||||
|
|
||||||
case $state in
|
case $state in
|
||||||
(command)
|
(command)
|
||||||
|
|
||||||
local -a subcommands
|
local -a subcommands
|
||||||
subcommands=(
|
subcommands=(
|
||||||
'start:Start a new support branch.'
|
'start:Start a new support branch.'
|
||||||
'list:List all your support branches. (Alias to `git flow support`)'
|
'list:List all your support branches. (Alias to `git flow support`)'
|
||||||
)
|
)
|
||||||
_describe -t commands 'git flow support' subcommands
|
_describe -t commands 'git flow support' subcommands
|
||||||
_arguments \
|
_arguments \
|
||||||
-v'[Verbose (more) output]'
|
-v'[Verbose (more) output]'
|
||||||
;;
|
;;
|
||||||
|
|
||||||
(options)
|
(options)
|
||||||
case $line[1] in
|
case $line[1] in
|
||||||
|
|
||||||
(start)
|
(start)
|
||||||
_arguments \
|
_arguments \
|
||||||
-F'[Fetch from origin before performing finish]'\
|
-F'[Fetch from origin before performing finish]'\
|
||||||
':feature:__git_flow_support_list'\
|
':feature:__git_flow_support_list'\
|
||||||
':branch-name:__git_branch_names'
|
':branch-name:__git_branch_names'
|
||||||
;;
|
;;
|
||||||
|
|
||||||
*)
|
*)
|
||||||
_arguments \
|
_arguments \
|
||||||
-v'[Verbose (more) output]'
|
-v'[Verbose (more) output]'
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
__git_flow_version_list ()
|
__git_flow_version_list () {
|
||||||
{
|
local expl
|
||||||
local expl
|
declare -a versions
|
||||||
declare -a versions
|
|
||||||
|
|
||||||
versions=(${${(f)"$(_call_program versions git flow release list 2> /dev/null | tr -d ' |*')"}})
|
versions=(${${(f)"$(_call_program versions git flow release list 2> /dev/null | tr -d ' |*')"}})
|
||||||
__git_command_successful || return
|
__git_command_successful || return
|
||||||
|
|
||||||
_wanted versions expl 'version' compadd $versions
|
_wanted versions expl 'version' compadd $versions
|
||||||
}
|
}
|
||||||
|
|
||||||
__git_flow_feature_list ()
|
__git_flow_feature_list () {
|
||||||
{
|
local expl
|
||||||
local expl
|
declare -a features
|
||||||
declare -a features
|
|
||||||
|
|
||||||
features=(${${(f)"$(_call_program features git flow feature list 2> /dev/null | tr -d ' |*')"}})
|
features=(${${(f)"$(_call_program features git flow feature list 2> /dev/null | tr -d ' |*')"}})
|
||||||
__git_command_successful || return
|
__git_command_successful || return
|
||||||
|
|
||||||
_wanted features expl 'feature' compadd $features
|
_wanted features expl 'feature' compadd $features
|
||||||
}
|
}
|
||||||
|
|
||||||
__git_remotes () {
|
__git_remotes () {
|
||||||
local expl gitdir remotes
|
local expl gitdir remotes
|
||||||
|
|
||||||
gitdir=$(_call_program gitdir git rev-parse --git-dir 2>/dev/null)
|
gitdir=$(_call_program gitdir git rev-parse --git-dir 2>/dev/null)
|
||||||
__git_command_successful || return
|
__git_command_successful || return
|
||||||
|
|
||||||
remotes=(${${(f)"$(_call_program remotes git config --get-regexp '"^remote\..*\.url$"')"}//#(#b)remote.(*).url */$match[1]})
|
remotes=(${${(f)"$(_call_program remotes git config --get-regexp '"^remote\..*\.url$"')"}//#(#b)remote.(*).url */$match[1]})
|
||||||
__git_command_successful || return
|
__git_command_successful || return
|
||||||
|
|
||||||
# TODO: Should combine the two instead of either or.
|
# TODO: Should combine the two instead of either or.
|
||||||
if (( $#remotes > 0 )); then
|
if (( $#remotes > 0 )); then
|
||||||
_wanted remotes expl remote compadd $* - $remotes
|
_wanted remotes expl remote compadd $* - $remotes
|
||||||
else
|
else
|
||||||
_wanted remotes expl remote _files $* - -W "($gitdir/remotes)" -g "$gitdir/remotes/*"
|
_wanted remotes expl remote _files $* - -W "($gitdir/remotes)" -g "$gitdir/remotes/*"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
__git_flow_hotfix_list ()
|
__git_flow_hotfix_list () {
|
||||||
{
|
local expl
|
||||||
local expl
|
declare -a hotfixes
|
||||||
declare -a hotfixes
|
|
||||||
|
|
||||||
hotfixes=(${${(f)"$(_call_program hotfixes git flow hotfix list 2> /dev/null | tr -d ' |*')"}})
|
hotfixes=(${${(f)"$(_call_program hotfixes git flow hotfix list 2> /dev/null | tr -d ' |*')"}})
|
||||||
__git_command_successful || return
|
__git_command_successful || return
|
||||||
|
|
||||||
_wanted hotfixes expl 'hotfix' compadd $hotfixes
|
_wanted hotfixes expl 'hotfix' compadd $hotfixes
|
||||||
}
|
}
|
||||||
|
|
||||||
__git_flow_support_list ()
|
__git_flow_support_list () {
|
||||||
{
|
local expl
|
||||||
local expl
|
declare -a support
|
||||||
declare -a support
|
|
||||||
|
|
||||||
support=(${${(f)"$(_call_program support git flow support list 2> /dev/null | tr -d ' |*')"}})
|
support=(${${(f)"$(_call_program support git flow support list 2> /dev/null | tr -d ' |*')"}})
|
||||||
__git_command_successful || return
|
__git_command_successful || return
|
||||||
|
|
||||||
_wanted hotfixes expl 'support' compadd $support
|
_wanted hotfixes expl 'support' compadd $support
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
__git_branch_names () {
|
__git_branch_names () {
|
||||||
local expl
|
local expl
|
||||||
declare -a branch_names
|
declare -a branch_names
|
||||||
|
|
||||||
branch_names=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/heads 2>/dev/null)"}#refs/heads/})
|
branch_names=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/heads 2>/dev/null)"}#refs/heads/})
|
||||||
__git_command_successful || return
|
__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 () {
|
__git_command_successful () {
|
||||||
if (( ${#pipestatus:#0} > 0 )); then
|
if (( ${#pipestatus:#0} > 0 )); then
|
||||||
_message 'not a git repository'
|
_message 'not a git repository'
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
_git-flow "$@"
|
_git-flow "$@"
|
||||||
|
|
|
||||||
|
|
@ -230,7 +230,7 @@ _language_codes() {
|
||||||
|
|
||||||
case $command in
|
case $command in
|
||||||
ISO-639-1)
|
ISO-639-1)
|
||||||
_language_codes_${${command//-/_}:l} "${@[1,-2]}" && ret=0
|
_language_codes_${${command//-/_}:l} "${@[1,-2]}" && ret=0
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
_message "unknown command: $command"
|
_message "unknown command: $command"
|
||||||
|
|
|
||||||
516
src/_nftables
516
src/_nftables
|
|
@ -12,278 +12,280 @@
|
||||||
# * Markus Richter ( https://github.com/mqus , <mqus@disroot.org>)
|
# * Markus Richter ( https://github.com/mqus , <mqus@disroot.org>)
|
||||||
#
|
#
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
_nft(){
|
_nft(){
|
||||||
local -a rules states prev args families options descriptors
|
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 state="start" line nextstate cmd_obj cmd_subcmd cmd_fam cmd_tab cmd_chain #curcontext="$curcontext"
|
||||||
|
|
||||||
options=(
|
options=(
|
||||||
'(-)'{-h,--help}'[show help]' \
|
'(-)'{-h,--help}'[show help]'
|
||||||
'(-)'{-v,--version}'[print version information]' \
|
'(-)'{-v,--version}'[print version information]'
|
||||||
"(-i --interactive)"{-i,--interactive}'[read input from interactive CLI]: :->end' \
|
"(-i --interactive)"{-i,--interactive}'[read input from interactive CLI]: :->end'
|
||||||
"(-f --file)"{-f,--file}'[read input from <filename>]:nftables rule file:_files' \
|
"(-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]" \
|
'(-c --check -n --numeric -N)'{-c,--check}"[check command's validity without actually applying the changes]"
|
||||||
'(-j --json)'{-j,--json}'[format output in json]' \
|
'(-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]' \
|
'(-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]' \
|
'(-s --stateless)'{-s,--stateless}'[omit stateful information of ruleset]'
|
||||||
'(-N -n --numeric -c --check)'-N'[translate IP addresses to names]' \
|
'(-N -n --numeric -c --check)'-N'[translate IP addresses to names]'
|
||||||
'(-a --handle)'{-a,--handle}'[output rule handle]' \
|
'(-a --handle)'{-a,--handle}'[output rule handle]'
|
||||||
'(-e --echo)'{-e,--echo}'[echo what has been added, inserted or replaced]' \
|
'(-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'
|
{-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
|
# 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
|
# 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
|
# 'descriptors' for _arguments, which essentially tells _arguments how to complete
|
||||||
local _i=0
|
local _i=0
|
||||||
while true;do
|
while true;do
|
||||||
(( _i+=1 ))
|
(( _i+=1 ))
|
||||||
#Guard for endless loops
|
#Guard for endless loops
|
||||||
[[ $_i -gt 100 ]] && return 1
|
[[ $_i -gt 100 ]] && return 1
|
||||||
|
|
||||||
descriptors=()
|
descriptors=()
|
||||||
nextstate="end"
|
nextstate="end"
|
||||||
case $state in
|
case $state in
|
||||||
(start)
|
(start)
|
||||||
##if line is empty (at the start) or ends with semicolon, autocomplete subcommands,
|
##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
|
# else if we are after a space,complete a semicolon (end the current nft command) and start anew
|
||||||
if [[ $line[1] = "" || $line[1] =~ ';$' ]] ; then
|
if [[ $line[1] = "" || $line[1] =~ ';$' ]] ; then
|
||||||
descriptors=( ":: :_nft_subcommands" )
|
descriptors=( ":: :_nft_subcommands" )
|
||||||
nextstate="category"
|
nextstate="category"
|
||||||
else
|
else
|
||||||
if [[ $words =~ ' $' ]]; then
|
if [[ $words =~ ' $' ]]; then
|
||||||
descriptors=(':: :(\;)')
|
descriptors=(':: :(\;)')
|
||||||
else
|
else
|
||||||
descriptors=(':argument: ')
|
descriptors=(':argument: ')
|
||||||
fi
|
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"
|
nextstate="start"
|
||||||
fi
|
;;
|
||||||
;;
|
(add-element | delete-element)
|
||||||
(category)
|
cmd_tab=$line[1]
|
||||||
case $line[1] in
|
descriptors=(": : _nft_object $cmd_fam $cmd_tab '\(map\|set\)' false")
|
||||||
(add | list | flush | delete | create | rename | insert | replace | reset)
|
nextstate="start"
|
||||||
descriptors=( ":: :_nft_${line[1]}" )
|
;;
|
||||||
nextstate=$line[1]
|
#TODO:
|
||||||
;;
|
#(add-set | add-map)
|
||||||
(monitor)
|
#(add-flowtable)
|
||||||
descriptors=( ":: : _nft_mon_filter" )
|
#("add-ct\ helper")
|
||||||
nextstate="mon1"
|
#(add-counter)
|
||||||
;;
|
#(add-quota)
|
||||||
(export)
|
|
||||||
descriptors=( ":: :(ruleset)" ":: :_nft_out_format" )
|
|
||||||
nextstate="preend"
|
|
||||||
;;
|
|
||||||
(describe)
|
|
||||||
descriptors=( ":expression: ")
|
|
||||||
nextstate="start" #x restart
|
|
||||||
;;
|
|
||||||
(*)
|
|
||||||
return 1;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
#descriptors=( "(ruleset)" )
|
(*)
|
||||||
#nextstate="end"
|
return 1;
|
||||||
;;
|
;;
|
||||||
(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
|
esac
|
||||||
;;
|
_arguments -C -s \
|
||||||
#all completions for create and insert match with the completions of add
|
"${options[@]}" \
|
||||||
(create | insert)
|
"${descriptors[@]}" \
|
||||||
state="add"
|
"*:: :->$nextstate" \
|
||||||
;|
|
&& return 0;
|
||||||
#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)
|
|
||||||
|
|
||||||
(*)
|
done
|
||||||
return 1;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
_arguments -C -s \
|
|
||||||
"${options[@]}" \
|
|
||||||
"${descriptors[@]}" \
|
|
||||||
"*:: :->$nextstate" \
|
|
||||||
&& return 0;
|
|
||||||
|
|
||||||
done
|
|
||||||
} # end _nft
|
} # end _nft
|
||||||
|
|
||||||
_nft_subcommands(){
|
_nft_subcommands(){
|
||||||
local commands=(
|
local commands=(
|
||||||
'add:add a table, chain, rule, set, map, or object'
|
'add:add a table, chain, rule, set, map, or object'
|
||||||
'list:list a ruleset, table, chain, 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'
|
'flush:flush (delete everything from) a ruleset, table, chain, set, or map'
|
||||||
'export:print the ruleset in a machine readable format (json or xml)'
|
'export:print the ruleset in a machine readable format (json or xml)'
|
||||||
'delete:delete a table, chain, rule, set, element, map, or object'
|
'delete:delete a table, chain, rule, set, element, map, or object'
|
||||||
'create:similar to add but returns an error for existing chain'
|
'create:similar to add but returns an error for existing chain'
|
||||||
'rename:rename the specified 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'
|
'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'
|
'replace:similar to the add command, but replaces the specified rule'
|
||||||
'reset:list-and-reset stateful object'
|
'reset:list-and-reset stateful object'
|
||||||
'monitor:listen to Netlink events'
|
'monitor:listen to Netlink events'
|
||||||
'describe:show information about the type of an expression and its data type'
|
'describe:show information about the type of an expression and its data type'
|
||||||
)
|
)
|
||||||
_describe -t commands 'nft subcommand' commands "$@"
|
_describe -t commands 'nft subcommand' commands "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
_nft_mon_filter(){
|
_nft_mon_filter(){
|
||||||
local monitor_filters=(
|
local monitor_filters=(
|
||||||
'new:show only events of created objects'
|
'new:show only events of created objects'
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue