Compare commits

...

28 Commits

Author SHA1 Message Date
Shohei YOSHIDA bce05f9352
Merge pull request #1236 from zsh-users/refactor_gist
Refactor gist and fix cache broken cache implementation
2026-03-16 15:10:54 +09:00
Shohei YOSHIDA 504b84f000
Merge pull request #1235 from zsh-users/refactor_cmake
Refactor cmake completion
2026-03-16 15:09:55 +09:00
Shohei YOSHIDA 84d9053354
Merge pull request #1234 from zsh-users/refactor_cf
Refactoring _cf completion
2026-03-16 14:54:01 +09:00
Shohei YOSHIDA 51025ba738
Merge pull request #1237 from zsh-users/refactor-cask
Refactor cask completion
2026-03-16 14:37:26 +09:00
Shohei YOSHIDA 83748eefc0
Merge pull request #1238 from zsh-users/refactor_git_flow
Refactor git flow
2026-03-16 14:13:23 +09:00
Shohei YOSHIDA 8ef1a35c32
Merge pull request #1239 from zsh-users/refactor_openvpn3
Refactor openvpn3
2026-03-16 14:12:18 +09:00
Shohei YOSHIDA f1cd0e8940
Merge pull request #1233 from zsh-users/refactor_tmuxp
refactoring _tmuxp
2026-03-16 14:11:56 +09:00
Shohei YOSHIDA 31236f26de
Use git_flow prefix instead of git for functions 2026-03-15 22:14:52 +09:00
Shohei YOSHIDA 8758ee4809
Use local variables 2026-03-15 22:11:41 +09:00
Shohei YOSHIDA 45f8084e70
Don't use global variables 2026-03-15 22:09:37 +09:00
Shohei YOSHIDA d1180f126a
Add global options 2026-03-15 15:14:40 +09:00
Shohei YOSHIDA 96316552ea
Merge two switch-case 2026-03-15 15:08:37 +09:00
Shohei YOSHIDA 0dce3a833b
Don't overwrite context variables 2026-03-15 15:08:30 +09:00
Shohei YOSHIDA da6814a485
Don't use global variables 2026-03-15 15:04:17 +09:00
Shohei YOSHIDA b9c943a9e8
Fix cache implementation 2026-03-15 13:24:57 +09:00
Shohei YOSHIDA 5c4fd5c1c5
Don't use global variables 2026-03-15 12:08:49 +09:00
Shohei YOSHIDA e534d39076
simplify assignments and remove needless functions 2026-03-14 21:04:01 +09:00
Shohei YOSHIDA 8e505348f3
Reduce top level local variables, use function local variables instead 2026-03-14 20:56:20 +09:00
Shohei YOSHIDA 309d615eb5
Simplify cmake targets
- Don't use for loop
- Use reduce filtering commands
2026-03-14 20:27:54 +09:00
Shohei YOSHIDA 9240b691d0
Do not use global variables 2026-03-14 20:06:03 +09:00
Shohei YOSHIDA 003afbe513
Refactoring _cf completion
- don't overwrite global variables
- add `__cf_` prefix to private functions
- improve command function dispatch
- use zsh way for array value check
2026-03-14 01:01:16 +09:00
Shohei YOSHIDA f1153d7a9d
add command name prefix to functions 2026-03-14 00:17:55 +09:00
Shohei YOSHIDA ce3bdfed22
Merge pull request #1232 from zsh-users/fix-format
Fix format issues
2026-03-13 16:30:56 +09:00
Shohei YOSHIDA fe94956940
Merge pull request #1231 from zsh-users/issue-1214
`--build` option should be an optional parameter
2026-03-13 16:01:19 +09:00
Shohei YOSHIDA b5da595150
Fix indentation size 2026-03-13 11:46:25 +09:00
Shohei YOSHIDA 7ea6b7a971
Add editor settings to all files 2026-03-13 11:38:48 +09:00
Shohei YOSHIDA 32210c83c5
Use spaces instead of tabs 2026-03-13 11:31:47 +09:00
Shohei YOSHIDA 867fb5a09c
`--build` option should be an optional parameter 2026-03-12 13:38:49 +09:00
27 changed files with 1548 additions and 1706 deletions

View File

@ -69,3 +69,10 @@ esac
return $ret 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

View File

@ -41,14 +41,29 @@
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
function _cask() { function _cask() {
local ret=1 state typeset -A opt_args
_arguments \ local context state line ret=1
local curcontext="$curcontext"
_arguments -C \
'(--proxy --http-proxy --https-proxy)--proxy[Set emacs proxy for HTTPS and HTTPS]:host:_hosts' \
'(--proxy --http-proxy)--http-proxy[Set emacs proxy for HTTP]:host:_hosts' \
'(--proxy --https-proxy)--https-proxy[Set emacs proxy for HTTPS]:host:_hosts' \
'(--proxy --http-proxy --https-proxy)--proxy[Set emacs proxy for HTTPS and HTTPS]:host:_hosts' \
'--no-proxy[Set Emacs no-proxy to HOST]:host:_hosts' \
'(- *)--version[Print Cask version and exit]' \
'(- *)'{-h,--help}'[Display usage or information for command]::command:->subcommand' \
'--debug[Turn on debug output]' \
'--path[Run command in this PATH instead of default-directory]:dir:_files -/' \
'(--verbose --silent)--verbose[Be verbose and show debug output]' \
'(--verbose --silent)--verbose[Be slient and do not show anything]' \
':subcommand:->subcommand' \ ':subcommand:->subcommand' \
'*:: :->subcmds' && ret=0 '*:: :->subcmds' \
&& ret=0
case $state in case $state in
subcommand) (subcommand)
subcommands=( local -a subcommands=(
"build:build all Elisp files in the files directive" "build:build all Elisp files in the files directive"
"clean-elc:remove all byte compiled Elisp files in the files directive" "clean-elc:remove all byte compiled Elisp files in the files directive"
"exec:execute command with correct 'exec-path' and 'load-path'" "exec:execute command with correct 'exec-path' and 'load-path'"
@ -71,19 +86,32 @@ function _cask() {
"upgrade:upgrade Cask itself and its dependencies" "upgrade:upgrade Cask itself and its dependencies"
"version:print program version" "version:print program version"
) )
_describe -t subcommands 'cask subcommands' subcommands && ret=0
esac
_describe -t subcommands 'cask subcommands' subcommands && ret=0
;;
(subcmds)
case "$words[1]" in case "$words[1]" in
init) (init)
_arguments \ _arguments \
'(--dev)--dev[Run in dev mode]' && ret=0 ;; '(--dev)--dev[Run in dev mode]' \
exec) && ret=0
;;
(exec)
_generic _generic
;; ;;
esac esac
;;
esac
return ret return ret
} }
_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

719
src/_cf

File diff suppressed because it is too large Load Diff

View File

@ -79,12 +79,12 @@ local -a cmake_build_options=(
'--list-presets[List available presets]' '--list-presets[List available presets]'
'--workflow[Run a workflow preset]' '--workflow[Run a workflow preset]'
'-E[CMake command mode]:command:_cmake_command_help' '-E[CMake command mode]:command:_cmake_commands'
'-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]"' '-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]' '--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 -/' '--install[Install a CMake-generated project binary tree]:project directory:_path_files -/'
'--open[Open generated project in the associated application]:project directory:_path_files -/' '--open[Open generated project in the associated application]:project directory:_path_files -/'
@ -149,11 +149,11 @@ _cmake_generator_options() {
# -------------- # --------------
(( $+functions[_cmake_presets] )) || (( $+functions[_cmake_presets] )) ||
_cmake_presets() { _cmake_presets() {
local invoke; invoke=(${(Q)words}) local invoke=(${(Q)words})
invoke[$CURRENT]=() invoke[$CURRENT]=()
# TODO: remove all arguments -* except -S # TODO: remove all arguments -* except -S
local list_presets; list_presets=(${(f)"$(${invoke} --list-presets 2>/dev/null | local list_presets=(${(f)"$(${invoke} --list-presets 2>/dev/null |
sed -n -e 's,^[[:space:]]*"\([^"]*\)"[[:space:]]*-[[:space:]]*\(.*\),\1:\2,p' \ sed -n -e 's,^[[:space:]]*"\([^"]*\)"[[:space:]]*-[[:space:]]*\(.*\),\1:\2,p' \
-e 's,^[[:space:]]*"\([^"]*\)"[[:space:]]*$,\1,p')"}) -e 's,^[[:space:]]*"\([^"]*\)"[[:space:]]*$,\1,p')"})
@ -165,24 +165,16 @@ _cmake_presets() {
# -------------- # --------------
(( $+functions[_cmake_targets] )) || (( $+functions[_cmake_targets] )) ||
_cmake_targets() { _cmake_targets() {
local -a targets local dir="$1"
if [ -f $1/Makefile ] local -a targets=()
then if [[ -f "${dir}/Makefile" && $+commands[make] ]]; then
# `make help` doesn't work for Makefiles in general, but for CMake generated Makefiles it does. # `make help` doesn't work for Makefiles in general, but for CMake generated Makefiles it does.
i=1 targets=(${(f)"$(make -f $dir/Makefile help 2>/dev/null | awk '/^\.\.\./ { print $2 }')"})
for target in $(make -f $1/Makefile help | \grep -e "\.\.\." | sed "s/\.\.\. //" | sed "s/ (the default.*//") ; do elif [[ -f "${dir}/build.ninja" && $+commands[ninja] ]]; then
targets[$i]=$target
(( i = $i + 1 ))
done
elif [ -f $1/build.ninja ]
then
# `ninja help` doesn't seem to be the list of targets we're interested in # `ninja help` doesn't seem to be the list of targets we're interested in
i=1 targets=(${(f)"$(ninja -C $dir -t targets all 2>/dev/null | awk -F: '{print $1}' )"})
for target in $(ninja -C $1 -t targets all 2&>/dev/null | awk -F: '{print $1}') ; do
targets[$i]="$target"
(( i++ ))
done
fi fi
_describe 'build targets' targets _describe 'build targets' targets
} }
@ -195,44 +187,53 @@ _cmake_suggest_installdirs() {
} }
_cmake_on_build() { _cmake_on_build() {
local build_extras;build_extras=( local build_extras=(
'--[Native build tool options]' '--[Native build tool options]'
'--target[specify build target]' '--target[specify build target]'
'--clean-first[build target clean first]' '--clean-first[build target clean first]'
'--config[For multi-configuration tools]' '--config[For multi-configuration tools]'
'--parallel[maximum number of build processes]' '--parallel[maximum number of build processes]'
'--use-stderr') '--use-stderr'
)
local -a undescribed_build_extras local -a undescribed_build_extras
i=1 local i=1
for be in $build_extras ; do for be in $build_extras ; do
undescribed_build_extras[$i]=$(echo $be | sed "s/\[.*//") undescribed_build_extras[$i]=$(echo $be | sed "s/\[.*//")
(( i++ )) (( i++ ))
done done
inbuild=false
dashdashposition=-1 local in_build=false
local dash_dash_position=-1
local build_at=$CURRENT
for ((i = (($CURRENT - 1)); i > 1 ; i--)); do for ((i = (($CURRENT - 1)); i > 1 ; i--)); do
if [[ $words[$i] == --build ]] ; then if [[ $words[$i] == --build ]]; then
inbuild=true in_build=true
buildat=$i build_at=$i
(( difference = $CURRENT - $i )) (( difference = $CURRENT - $i ))
elif [[ $words[$i] == -- ]] ; then elif [[ $words[$i] == -- ]]; then
dashdashposition=$i dash_dash_position=$i
fi fi
done done
# check if build mode has been left # check if build mode has been left
outofbuild=false local out_of_build=false
for ((i = (($CURRENT - 1)); i > (($buildat + 1)); i--)); do for ((i = (($CURRENT - 1)); i > (($build_at + 1)); i--)); do
# don't check the word after --build (should be a directory) # don't check the word after --build (should be a directory)
if [[ ${undescribed_build_extras[(r)$words[$i]]} == $words[$i] ]] ; then continue ; fi if [[ ${undescribed_build_extras[(r)$words[$i]]} == $words[$i] ]]; then
if [[ $words[(($i - 1))] == --target ]] ; then continue ; fi continue
if [[ $words[(($i - 1))] == --config ]] ; then continue ; fi
if [[ $words[(($i - 1))] == --parallel ]] ; then continue ; fi
outofbuild=true
done
if (( $dashdashposition > 0 )) ; then
_cmake_generator_options $words[(($buildat + 1))] $dashdashposition && return 0
fi fi
if [[ "$inbuild" == false || "$difference" -eq 1 ]] ; then
if [[ $words[(($i - 1))] == --target ]]; then continue ; fi
if [[ $words[(($i - 1))] == --config ]]; then continue ; fi
if [[ $words[(($i - 1))] == --parallel ]] ; then continue ; fi
out_of_build=true
done
if (( $dash_dash_position > 0 )) ; then
_cmake_generator_options $words[(($build_at + 1))] $dash_dash_position && return 0
fi
if [[ "$in_build" == false || "$difference" -eq 1 ]] ; then
# either there is no --build or completing the directory after --build # either there is no --build or completing the directory after --build
_arguments -C -s \ _arguments -C -s \
- build_opts \ - build_opts \
@ -241,14 +242,14 @@ _cmake_on_build() {
"$cmake_suggest_build[@]" && return 0 "$cmake_suggest_build[@]" && return 0
elif [[ $words[(($CURRENT - 1))] == --target ]] ; then elif [[ $words[(($CURRENT - 1))] == --target ]] ; then
# after --build <dir> --target, suggest targets # after --build <dir> --target, suggest targets
_cmake_targets $words[(($buildat + 1))] && return 0 _cmake_targets $words[(($build_at + 1))] && return 0
elif [[ $words[(($CURRENT - 1))] == --config ]] ; then elif [[ $words[(($CURRENT - 1))] == --config ]] ; then
# after --build <dir> --config, no idea # after --build <dir> --config, no idea
return 0 return 0
elif [[ $words[(($CURRENT - 1))] == --parallel ]] ; then elif [[ $words[(($CURRENT - 1))] == --parallel ]] ; then
# after --build <dir> --parallel # after --build <dir> --parallel
return 0 return 0
elif [ "$outofbuild" = true ] ; then elif [ "$out_of_build" = true ] ; then
# after --build <dir> --<not a --build option>, suggest other cmake_build_options (like -Wno-dev) # after --build <dir> --<not a --build option>, suggest other cmake_build_options (like -Wno-dev)
_arguments "$cmake_build_options[@]" && return 0 _arguments "$cmake_build_options[@]" && return 0
else else
@ -258,43 +259,49 @@ _cmake_on_build() {
} }
_cmake_on_install() { _cmake_on_install() {
local build_extras;build_extras=( local build_extras=(
'--[Native build tool options]' '--[Native build tool options]'
'--prefix[Override the installation prefix, CMAKE_INSTALL_PREFIX]' '--prefix[Override the installation prefix, CMAKE_INSTALL_PREFIX]'
'--config[For multi-configuration generators(e.g. Visual Studio)]' '--config[For multi-configuration generators(e.g. Visual Studio)]'
'--component[Component-based install]' '--component[Component-based install]'
'--strip[Strip before installing.]' '--strip[Strip before installing.]'
) )
local -a undescribed_build_extras local -a undescribed_build_extras
i=1 local i=1
for be in $build_extras ; do for be in $build_extras ; do
undescribed_build_extras[$i]=$(echo $be | sed "s/\[.*//") undescribed_build_extras[$i]=$(echo $be | sed "s/\[.*//")
(( i++ )) (( i++ ))
done done
inbuild=false
dashdashposition=-1 local in_build=false
local dash_dash_position=-1
local build_at=$CURRENT
for ((i = (($CURRENT - 1)); i > 1 ; i--)); do for ((i = (($CURRENT - 1)); i > 1 ; i--)); do
if [[ $words[$i] == --install ]] ; then if [[ $words[$i] == --install ]]; then
inbuild=true in_build=true
buildat=$i build_at=$i
(( difference = $CURRENT - $i )) (( difference = $CURRENT - $i ))
elif [[ $words[$i] == -- ]] ; then elif [[ $words[$i] == -- ]]; then
dashdashposition=$i dash_dash_position=$i
fi fi
done done
outofbuild=false
for ((i = (($CURRENT - 1)); i > (($buildat + 1)); i--)); do local out_of_build=false
for ((i = (($CURRENT - 1)); i > (($build_at + 1)); i--)); do
# don't check the word after --install (should be a directory) # don't check the word after --install (should be a directory)
if [[ ${undescribed_build_extras[(r)$words[$i]]} == $words[$i] ]] ; then continue ; fi if [[ ${undescribed_build_extras[(r)$words[$i]]} == $words[$i] ]] ; then continue ; fi
if [[ $words[(($i - 1))] == --prefix ]] ; then continue ; fi if [[ $words[(($i - 1))] == --prefix ]]; then continue ; fi
if [[ $words[(($i - 1))] == --config ]] ; then continue ; fi if [[ $words[(($i - 1))] == --config ]]; then continue ; fi
if [[ $words[(($i - 1))] == --component ]] ; then continue ; fi if [[ $words[(($i - 1))] == --component ]]; then continue ; fi
outofbuild=true out_of_build=true
done done
if (( $dashdashposition > 0 )) ; then
_cmake_generator_options $words[(($buildat + 1))] $dashdashposition && return 0 if (( $dash_dash_position > 0 )) ; then
_cmake_generator_options $words[(($build_at + 1))] $dash_dash_position && return 0
fi fi
if [[ "$inbuild" == false || "$difference" -eq 1 ]] ; then
if [[ "$in_build" == false || "$difference" -eq 1 ]] ; then
# either there is no --install or completing the directory after --install # either there is no --install or completing the directory after --install
_arguments -C -s \ _arguments -C -s \
- build_opts \ - build_opts \
@ -310,7 +317,7 @@ _cmake_on_install() {
elif [[ $words[(($CURRENT - 1))] == --component ]] ; then elif [[ $words[(($CURRENT - 1))] == --component ]] ; then
# after --build <dir> --component, no idea # after --build <dir> --component, no idea
return 0 return 0
elif [ "$outofbuild" = true ] ; then elif [ "$out_of_build" = true ] ; then
# after --build <dir> --<not a --build option>, suggest other cmake_build_options (like -Wno-dev) # after --build <dir> --<not a --build option>, suggest other cmake_build_options (like -Wno-dev)
_arguments "$cmake_build_options[@]" && return 0 _arguments "$cmake_build_options[@]" && return 0
else else
@ -341,19 +348,16 @@ local -a cmake_help_actions=(
'(- 1)--help-variable-list[List variables with help available and exit]' '(- 1)--help-variable-list[List variables with help available and exit]'
'(- 1)--help-variables[Print cmake-variables manual and exit]' '(- 1)--help-variables[Print cmake-variables manual and exit]'
) )
_cmake_help() {
_arguments -C -s - help "$cmake_help_actions[@]"
}
# ----------------- # -----------------
# _cmake_list_names # _cmake_list_names
# ----------------- # -----------------
(( $+functions[_cmake_list_names] )) || (( $+functions[_cmake_list_names] )) ||
_cmake_list_names() { _cmake_list_names() {
local command; command="$@[1]" local command="$@[1]"
local desc; desc="$@[2]" local desc="$@[2]"
local opts; opts=($@[3]) local opts=($@[3])
local list_names; list_names=(${(f)"$($service $command 2> /dev/null)"}) local list_names=(${(f)"$($service $command 2> /dev/null)"})
# Older CMake (< 3.0) writes out the version # Older CMake (< 3.0) writes out the version
list_names=(${^list_names##cmake version*}) list_names=(${^list_names##cmake version*})
@ -382,7 +386,7 @@ _cmake_define_property() {
# ---------------------------- # ----------------------------
(( $+functions[_cmake_define_property_names] )) || (( $+functions[_cmake_define_property_names] )) ||
_cmake_define_property_names() { _cmake_define_property_names() {
local alternatives; alternatives=( local alternatives=(
'common-property-names:common property name:_cmake_define_common_property_names -qS=' 'common-property-names:common property name:_cmake_define_common_property_names -qS='
) )
local -A cmake_langs local -A cmake_langs
@ -402,8 +406,9 @@ _cmake_define_property_names() {
# --------------------------------- # ---------------------------------
(( $+functions[_cmake_define_lang_property_names] )) || (( $+functions[_cmake_define_lang_property_names] )) ||
_cmake_define_lang_property_names() { _cmake_define_lang_property_names() {
local cmake_lang="$@[-2]" cmake_lang_desc="$@[-1]" local cmake_lang="$@[-2]"
local properties; properties=( local cmake_lang_desc="$@[-1]"
local -a properties=(
"CMAKE_${cmake_lang}_COMPILER:${cmake_lang_desc} compiler" "CMAKE_${cmake_lang}_COMPILER:${cmake_lang_desc} compiler"
"CMAKE_${cmake_lang}_COMPILER_LAUNCHER:${cmake_lang_desc} compiler launcher (e.g. ccache)" "CMAKE_${cmake_lang}_COMPILER_LAUNCHER:${cmake_lang_desc} compiler launcher (e.g. ccache)"
"CMAKE_${cmake_lang}_FLAGS:${cmake_lang_desc} compiler flags for all builds" "CMAKE_${cmake_lang}_FLAGS:${cmake_lang_desc} compiler flags for all builds"
@ -424,7 +429,7 @@ _cmake_define_lang_property_names() {
# ----------------------------------- # -----------------------------------
(( $+functions[_cmake_define_common_property_names] )) || (( $+functions[_cmake_define_common_property_names] )) ||
_cmake_define_common_property_names() { _cmake_define_common_property_names() {
local properties; properties=( local -a properties=(
'CMAKE_MODULE_PATH:Search path for CMake modules (FindPROJECT.cmake)' 'CMAKE_MODULE_PATH:Search path for CMake modules (FindPROJECT.cmake)'
'CMAKE_PREFIX_PATH:Search path for installations (PROJECTConfig.cmake)' 'CMAKE_PREFIX_PATH:Search path for installations (PROJECTConfig.cmake)'
'CMAKE_BUILD_TYPE:Specifies the build type for make based generators' 'CMAKE_BUILD_TYPE:Specifies the build type for make based generators'
@ -438,51 +443,87 @@ _cmake_define_common_property_names() {
'CMAKE_UNITY_BUILD:Batch include source files' 'CMAKE_UNITY_BUILD:Batch include source files'
) )
_describe -t 'common-property-names' 'common property name' properties $@ _describe -t 'common-property-names' 'common property name' properties "$@"
} }
local _cmake_build_types=('Debug' 'Release' 'RelWithDebInfo' 'MinSizeRel')
local _cmake_c_standards=(90 99 11)
local _cmake_cxx_standards=(98 11 14 17 20)
# ---------------------------- # ----------------------------
# _cmake_define_property_values # _cmake_define_property_values
# ---------------------------- # ----------------------------
(( $+functions[_cmake_define_property_values] )) || (( $+functions[_cmake_define_property_values] )) ||
_cmake_define_property_values() { _cmake_define_property_values() {
local ret=1 local ret=1
local build_types=('Debug' 'Release' 'RelWithDebInfo' 'MinSizeRel')
local c_standards=(90 99 11 17 23)
local cxx_standards=(98 11 14 17 20 23)
setopt localoptions extendedglob setopt localoptions extendedglob
case $@[-1] in case $@[-1] in
(CMAKE_BUILD_TYPE) _wanted build-types expl 'build type' _values 'build type' ${_cmake_build_types[@]} && ret=0;; (CMAKE_BUILD_TYPE)
(BUILD_SHARED_LIBS) _wanted booleans expl 'boolean' _cmake_booleans && ret=0;; _wanted build-types expl 'build type' _values 'build type' ${build_types[@]} && ret=0
(CMAKE_CXX_STANDARD) _wanted cxx-standards expl 'cxx standard' _values 'cxx standard' ${_cmake_cxx_standards[@]} && ret=0;; ;;
(CMAKE_C_STANDARD) _wanted c-standards expl 'c standard' _values 'c standard' ${_cmake_c_standards[@]} && ret=0;; (BUILD_SHARED_LIBS)
(CMAKE_TOOLCHAIN_FILE) _wanted toolchain-files expl 'file' _cmake_toolchain_files && ret=0;; _wanted booleans expl 'boolean' _cmake_booleans && ret=0
(CMAKE_COLOR_MAKEFILE) _wanted booleans expl 'boolean' _cmake_booleans && ret=0;; ;;
(CMAKE_RULE_MESSAGES) _wanted booleans expl 'boolean' _cmake_booleans && ret=0;; (CMAKE_CXX_STANDARD)
(CMAKE_VERBOSE_MAKEFILE) _wanted booleans expl 'boolean' _cmake_booleans && ret=0;; _wanted cxx-standards expl 'cxx standard' _values 'cxx standard' ${cxx_standards[@]} && ret=0
(CMAKE_UNITY_BUILD) _wanted booleans expl 'boolean' _cmake_booleans && ret=0;; ;;
(CMAKE_INSTALL_PREFIX) _files -/ && ret=0;; (CMAKE_C_STANDARD)
(CMAKE_EXPORT_COMPILE_COMMANDS) _wanted booleans expl 'boolean' _cmake_booleans && ret=0;; _wanted c-standards expl 'c standard' _values 'c standard' ${c_standards[@]} && ret=0
(CMAKE_*_COMPILER) _wanted compilers expl 'compiler' _cmake_compilers && ret=0;; ;;
(CMAKE_*_COMPILER_LAUNCHER) _wanted compilers expl 'compiler launcher' _cmake_launchers && ret=0;; (CMAKE_TOOLCHAIN_FILE)
(CMAKE_*_FLAGS(|_?*)) _message -e compiler-flags 'compiler flags' && _dispatch $service -value-,CPPFLAGS,-default- && ret=0;; _wanted toolchain-files expl 'file' _cmake_toolchain_files && ret=0
(CMAKE_*_STANDARD_REQUIRED) _wanted booleans expl 'boolean' _cmake_booleans && ret=0;; ;;
(CMAKE_*_EXTENSIONS) _wanted booleans expl 'boolean' _cmake_booleans && ret=0;; (CMAKE_COLOR_MAKEFILE)
(*) _files && ret=0;; _wanted booleans expl 'boolean' _cmake_booleans && ret=0
;;
(CMAKE_RULE_MESSAGES)
_wanted booleans expl 'boolean' _cmake_booleans && ret=0
;;
(CMAKE_VERBOSE_MAKEFILE)
_wanted booleans expl 'boolean' _cmake_booleans && ret=0
;;
(CMAKE_UNITY_BUILD)
_wanted booleans expl 'boolean' _cmake_booleans && ret=0
;;
(CMAKE_INSTALL_PREFIX)
_files -/ && ret=0
;;
(CMAKE_EXPORT_COMPILE_COMMANDS)
_wanted booleans expl 'boolean' _cmake_booleans && ret=0
;;
(CMAKE_*_COMPILER)
_wanted compilers expl 'compiler' _cmake_compilers && ret=0
;;
(CMAKE_*_COMPILER_LAUNCHER)
_wanted compilers expl 'compiler launcher' _cmake_launchers && ret=0
;;
(CMAKE_*_FLAGS(|_?*))
_message -e compiler-flags 'compiler flags' && _dispatch $service -value-,CPPFLAGS,-default- && ret=0
;;
(CMAKE_*_STANDARD_REQUIRED)
_wanted booleans expl 'boolean' _cmake_booleans && ret=0
;;
(CMAKE_*_EXTENSIONS)
_wanted booleans expl 'boolean' _cmake_booleans && ret=0
;;
(*)
_files && ret=0
;;
esac esac
return ret return ret
} }
local -a _cmake_generator_list=(${(f)"$(cmake --help | awk '/^Generators/{flag=1} flag && /^[* ] [^ ]/ {sub(/^[* ] /, ""); sub(/=.*$/, ""); sub(/\[arch\]/, ""); sub(/ *$/, ""); print}')"})
# ----------------- # -----------------
# _cmake_generators # _cmake_generators
# ----------------- # -----------------
(( $+functions[_cmake_generators] )) || (( $+functions[_cmake_generators] )) ||
_cmake_generators() { _cmake_generators() {
_describe -t generators 'generator' _cmake_generator_list local -a generators=(
${(f)"$(cmake --help | awk '/^Generators/{flag=1} flag && /^[* ] [^ ]/ {sub(/^[* ] /, ""); sub(/=.*$/, ""); sub(/\[arch\]/, ""); sub(/ *$/, ""); print}')"}
)
_describe -t generators 'generator' generators
} }
# ---------------------- # ----------------------
@ -519,45 +560,46 @@ _cmake_launchers() {
_command_names -e _command_names -e
} }
local -a _cmake_commands=( (( $+functions[_cmake_commands] )) ||
'capabilities:Report capabilities built into cmake in JSON format' \ _cmake_commands() {
'cat:concat the files and print them to the standard output' \ local -a commands=(
'chdir:run command in a given directory' \ 'capabilities:Report capabilities built into cmake in JSON format'
'compare_files:check if file1 is same as file2' \ 'cat:concat the files and print them to the standard output'
'copy:copy files to destination (either file or directory)' \ 'chdir:run command in a given directory'
'copy_directory:copy content of <dir>... directories to destination directory' \ 'compare_files:check if file1 is same as file2'
'copy_if_different:copy files if it has changed' \ 'copy:copy files to destination (either file or directory)'
'echo:displays arguments as text' \ 'copy_directory:copy content of <dir>... directories to destination directory'
'echo_append:displays arguments as text but no new line' \ 'copy_if_different:copy files if it has changed'
'env:run command in a modified environment' \ 'echo:displays arguments as text'
'environment:display the current environment' \ 'echo_append:displays arguments as text but no new line'
'make_directory:create parent and <dir> directories' \ 'env:run command in a modified environment'
'md5sum:create MD5 checksum of files' \ 'environment:display the current environment'
'sha1sum:create SHA1 checksum of files' \ 'make_directory:create parent and <dir> directories'
'sha224sum:create SHA224 checksum of files' \ 'md5sum:create MD5 checksum of files'
'sha256sum:create SHA256 checksum of files' \ 'sha1sum:create SHA1 checksum of files'
'sha384sum:create SHA384 checksum of files' \ 'sha224sum:create SHA224 checksum of files'
'sha512sum:create SHA512 checksum of files' \ 'sha256sum:create SHA256 checksum of files'
'remove:remove the file(s), use -f to force it' \ 'sha384sum:create SHA384 checksum of files'
'remove_directory:remove directories and their contents' \ 'sha512sum:create SHA512 checksum of files'
'rename:rename a file or directory (on one volume)' \ 'remove:remove the file(s), use -f to force it'
'rm:remove files or directories' \ 'remove_directory:remove directories and their contents'
'server:start cmake in server mode' \ 'rename:rename a file or directory (on one volume)'
'sleep:sleep for given number of seconds' \ 'rm:remove files or directories'
'tar:create or extract a tar or zip archive' \ 'server:start cmake in server mode'
'time:run command and display elapsed time' \ 'sleep:sleep for given number of seconds'
'touch:touch a <file>' \ 'tar:create or extract a tar or zip archive'
'touch_nocreate:touch a <file> but do not create it' \ 'time:run command and display elapsed time'
'create_symlink:create a symbolic link new -> old' \ 'touch:touch a <file>'
'create_hardlink:create a hard link new -> old' \ 'touch_nocreate:touch a <file> but do not create it'
'true:do nothing with an exit code of 0' \ 'create_symlink:create a symbolic link new -> old'
'create_hardlink:create a hard link new -> old'
'true:do nothing with an exit code of 0'
'false:do nothing with an exit code of 1' 'false:do nothing with an exit code of 1'
) )
_cmake_command() {
_arguments -C \
'-E[CMake command mode]:command:(("${_cmake_commands[@]}"))'
_describe -t commands 'command' commands
} }
local cmake_suggest_build;cmake_suggest_build=( local cmake_suggest_build;cmake_suggest_build=(
'--build[build]:build dir:_cmake_suggest_builddirs' '--build[build]:build dir:_cmake_suggest_builddirs'
) )
@ -573,21 +615,17 @@ elif [ $CURRENT -eq 2 ] ; then
- help \ - help \
"$cmake_help_actions[@]" \ "$cmake_help_actions[@]" \
- command \ - command \
'-E[CMake command mode]:command:( )' \ '-E[CMake command mode]:command:_cmake_commands' \
- build_opts \ - build_opts \
"$cmake_build_options[@]" \ "$cmake_build_options[@]" \
- build_cmds \ - build_cmds \
"$cmake_suggest_build[@]" \ "$cmake_suggest_build[@]" \
- install_cmds \ - install_cmds \
"$cmake_suggest_install[@]" && return 0 "$cmake_suggest_install[@]" && return 0
elif [[ $words[2] = --help* ]] ; then
_cmake_help
elif [[ $words[2] == --build ]] ; then elif [[ $words[2] == --build ]] ; then
_cmake_on_build _cmake_on_build
elif [[ $words[2] == --install ]] ; then elif [[ $words[2] == --install ]] ; then
_cmake_on_install _cmake_on_install
elif [[ $words[2] == -E ]]; then
_cmake_command
else else
_arguments "$cmake_build_options[@]" _arguments "$cmake_build_options[@]"
fi fi

View File

@ -40,10 +40,10 @@
# #
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
local curcontext="$curcontext" state line ret=1 _gist() {
typeset -A opt_args local ret=1
_arguments -C \ _arguments \
'(--login)--login[Authenticate gist on this computer.]' \ '(--login)--login[Authenticate gist on this computer.]' \
'(-f --filename)'{-f,--filename}'[Sets the filename and syntax type.]:NAME' \ '(-f --filename)'{-f,--filename}'[Sets the filename and syntax type.]:NAME' \
'(-t --type)'{-t,--type}'[Sets the file extension and syntax type.]:EXT' \ '(-t --type)'{-t,--type}'[Sets the file extension and syntax type.]:EXT' \
@ -51,19 +51,24 @@ _arguments -C \
'(--no-private -p --private)--no-private[Makes your gist no private.]' \ '(--no-private -p --private)--no-private[Makes your gist no private.]' \
'(-d --description)'{-d,--description}'[Adds a description to your gist.]:DESCRIPTION' \ '(-d --description)'{-d,--description}'[Adds a description to your gist.]:DESCRIPTION' \
'(-s --shorten)'{-s,--shorten}'[Shorten the gist URL using git.io.]' \ '(-s --shorten)'{-s,--shorten}'[Shorten the gist URL using git.io.]' \
'(-u --update)'{-u,--update}'[Update an existing gist.]:URL ID:user_gists' \ '(-u --update)'{-u,--update}'[Update an existing gist.]:URL ID:_gist_ids' \
'(-c --copy)'{-c,--copy}'[Copy the resulting URL to the clipboard]' \ '(-c --copy)'{-c,--copy}'[Copy the resulting URL to the clipboard]' \
'(-e --embed)'{-e,--embed}'[Copy the embed code for the gist to the clipboard]' \ '(-e --embed)'{-e,--embed}'[Copy the embed code for the gist to the clipboard]' \
'(-o --open --no-open)'{-o,--open}'[Open the resulting URL in a browser]' \ '(-o --open --no-open)'{-o,--open}'[Open the resulting URL in a browser]' \
'(--no-open -o --open)--no-open[No open the resulting URL in a browser]' \ '(--no-open -o --open)--no-open[No open the resulting URL in a browser]' \
'--skip-empty[Skip gisting empty files]' \
'(-P --paste)'{-P,--paste}'[Paste from the clipboard to gist]' \ '(-P --paste)'{-P,--paste}'[Paste from the clipboard to gist]' \
'(-R --raw)'{-R,--raw}'[Display raw URL of the new gist]' \ '(-R --raw)'{-R,--raw}'[Display raw URL of the new gist]' \
'(-l --list)'{-l,--list}'[List all gists for user ]::user' \ '(-l --list)'{-l,--list}'[List all gists for user ]::user' \
'(-h --help)'{-h,--help}'[print options help]' \ '--delete[Delete a gist]:id:_gist_ids' \
'(- *)'{-h,--help}'[print options help]' \
'(-v --version)'{-v,--version}'[print version]' \ '(-v --version)'{-v,--version}'[print version]' \
'(-r --read)'{-r,--read}'[Read a gist and print out the contents]:user gists:_gist_read_gists' \ '(-r --read)'{-r,--read}'[Read a gist and print out the contents]:user gists:_gist_ids' \
'*: :_files' && ret=0 '*: :_files' && ret=0
return ret
}
_gist_cache_policy() { _gist_cache_policy() {
# rebuild if cache is more than a day old # rebuild if cache is more than a day old
local -a oldp local -a oldp
@ -71,7 +76,7 @@ _gist_cache_policy() {
(( $#oldp )) (( $#oldp ))
} }
_gist_read_gists() { _gist_ids() {
local update_policy ret=1 local update_policy ret=1
zstyle -s ":completion:${curcontext}:" cache-policy update_policy zstyle -s ":completion:${curcontext}:" cache-policy update_policy
if [[ -z "$update_policy" ]]; then if [[ -z "$update_policy" ]]; then
@ -79,43 +84,33 @@ _gist_read_gists() {
fi fi
# stores the gists of the logged in user in the format ID[Description] # stores the gists of the logged in user in the format ID[Description]
_list=() local -a gist_list
_cached_gists="user_gists"
# retrieve/Write gists from/to cache # retrieve/Write gists from/to cache
if _cache_invalid $_cached_gists || ! _retrieve_cache $_cached_gists; then if _cache_invalid gist_cached_list || ! _retrieve_cache gist_cached_list; then
_gists=$(gist -l) if (( $+commands[ruby] )); then
gist_list=(${(f)"$(gist -l | ruby -ne 'puts "#{$1}:#{$2}" if $_ =~ %r{/([^/ ]+)\s+(.+)}')"})
elif (( $+commands[perl])); then
gist_list=(${(f)"$(gist -l | perl -wln -e 'm{/([^/ ]+)\s+(.+)} and print qq($1:$2)')"})
fi
if [ $? -eq 0 ]; then if [[ $? -eq 0 ]]; then
_store_cache $_cached_gists _gists _store_cache gist_cached_list gist_list
else else
# some error occurred, the user is probably not logged in # some error occurred, the user is probably not logged in
# set _gists to an empty string so that no completion is attempted # set _gists to an empty string so that no completion is attempted
_gists="" gist_list=()
fi fi
else
_retrieve_cache $_cached_gists
fi fi
if [ -n "$_gists" ]; then if [[ $#gist_list ]]; then
echo "$_gists" | while read -r line; do _describe -t gist_ids 'gist_ids' gist_list
# Splitting the gist -l output
url="$(echo "$line" | cut -d " " -f 1 | cut -d "/" -f 4)"
# gists w/o descriptions can have only one column in the output, those
# have their description set to an empty string
description="$(echo "$line" | awk '{if(NF > 1){$1=""; print $0}}')"
_list+=( "${url}[${description}]" )
done
_values "gists" $_list
ret=0
fi fi
return ret return ret
} }
return ret _gist "$@"
# Local Variables: # Local Variables:
# mode: Shell-Script # mode: Shell-Script

View File

@ -40,9 +40,7 @@
# #
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
_git-flow () {
_git-flow ()
{
local curcontext="$curcontext" state line local curcontext="$curcontext" state line
typeset -A opt_args typeset -A opt_args
@ -52,7 +50,6 @@ _git-flow ()
case $state in case $state in
(command) (command)
local -a subcommands local -a subcommands
subcommands=( subcommands=(
'init:Initialize a new git repo with support for the branching model.' 'init:Initialize a new git repo with support for the branching model.'
@ -67,28 +64,22 @@ _git-flow ()
(options) (options)
case $line[1] in case $line[1] in
(init) (init)
_arguments \ _arguments \
-f'[Force setting of gitflow branches, even if already configured]' \ -f'[Force setting of gitflow branches, even if already configured]' \
-d'[Use default branch naming conventions and prefixes]' -d'[Use default branch naming conventions and prefixes]'
;; ;;
(version) (version)
;; ;;
(hotfix) (hotfix)
__git-flow-hotfix __git-flow-hotfix
;; ;;
(release) (release)
__git-flow-release __git-flow-release
;; ;;
(feature) (feature)
__git-flow-feature __git-flow-feature
;; ;;
(support) (support)
__git-flow-support __git-flow-support
;; ;;
@ -98,8 +89,7 @@ _git-flow ()
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
@ -109,7 +99,6 @@ __git-flow-release ()
case $state in case $state in
(command) (command)
local -a subcommands local -a subcommands
subcommands=( subcommands=(
'start:Start a new release branch.' 'start:Start a new release branch.'
@ -125,13 +114,11 @@ __git-flow-release ()
(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]'\
':version:__git_flow_version_list' ':version:__git_flow_version_list'
;; ;;
(finish) (finish)
_arguments \ _arguments \
-F'[Fetch from origin before performing finish]' \ -F'[Fetch from origin before performing finish]' \
@ -143,19 +130,14 @@ __git-flow-release ()
-k'[Keep branch after performing finish]'\ -k'[Keep branch after performing finish]'\
':version:__git_flow_version_list' ':version:__git_flow_version_list'
;; ;;
(publish) (publish)
_arguments \ _arguments \
':version:__git_flow_version_list' ':version:__git_flow_version_list'
;; ;;
(track) (track)
_arguments \ _arguments \
':version:__git_flow_version_list' ':version:__git_flow_version_list'
;; ;;
*) *)
_arguments \ _arguments \
-v'[Verbose (more) output]' -v'[Verbose (more) output]'
@ -165,8 +147,7 @@ __git-flow-release ()
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
@ -176,7 +157,6 @@ __git-flow-hotfix ()
case $state in case $state in
(command) (command)
local -a subcommands local -a subcommands
subcommands=( subcommands=(
'start:Start a new hotfix branch.' 'start:Start a new hotfix branch.'
@ -191,12 +171,11 @@ __git-flow-hotfix ()
(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]'\
':hotfix:__git_flow_version_list'\ ':hotfix:__git_flow_version_list'\
':branch-name:__git_branch_names' ':branch-name:__git_flow_branch_names'
;; ;;
(finish) (finish)
@ -223,8 +202,7 @@ __git-flow-hotfix ()
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
@ -234,7 +212,6 @@ __git-flow-feature ()
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.'
@ -254,12 +231,11 @@ __git-flow-feature ()
(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_feature_list'\ ':feature:__git_flow_feature_list'\
':branch-name:__git_branch_names' ':branch-name:__git_flow_branch_names'
;; ;;
(finish) (finish)
@ -283,13 +259,13 @@ __git-flow-feature ()
(diff) (diff)
_arguments \ _arguments \
':branch:__git_branch_names'\ ':branch:__git_flow_branch_names'\
;; ;;
(rebase) (rebase)
_arguments \ _arguments \
-i'[Do an interactive rebase]' \ -i'[Do an interactive rebase]' \
':branch:__git_branch_names' ':branch:__git_flow_branch_names'
;; ;;
(checkout) (checkout)
@ -299,8 +275,8 @@ __git-flow-feature ()
(pull) (pull)
_arguments \ _arguments \
':remote:__git_remotes'\ ':remote:__git_flow_remote'\
':branch:__git_branch_names' ':branch:__git_flow_branch_names'
;; ;;
*) *)
@ -312,8 +288,7 @@ __git-flow-feature ()
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
@ -341,7 +316,7 @@ __git-flow-support ()
_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_flow_branch_names'
;; ;;
*) *)
@ -353,36 +328,30 @@ __git-flow-support ()
esac esac
} }
__git_flow_version_list () __git_flow_version_list() {
{
local expl local expl
declare -a versions local -a versions=(${${(f)"$(_call_program versions git flow release list 2> /dev/null | tr -d ' |*')"}})
__git_flow_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 () __git_flow_feature_list() {
{
local expl local expl
declare -a features local -a features=(${${(f)"$(_call_program features git flow feature list 2> /dev/null | tr -d ' |*')"}})
__git_flow_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 () { __git_flow_remote() {
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_flow_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_flow_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
@ -392,40 +361,31 @@ __git_remotes () {
fi fi
} }
__git_flow_hotfix_list () __git_flow_hotfix_list() {
{
local expl local expl
declare -a hotfixes local -a hotfixes=(${${(f)"$(_call_program hotfixes git flow hotfix list 2> /dev/null | tr -d ' |*')"}})
__git_flow_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 () __git_flow_support_list() {
{
local expl local expl
declare -a support local -a support=(${${(f)"$(_call_program support git flow support list 2> /dev/null | tr -d ' |*')"}})
__git_flow_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_flow_branch_names() {
__git_branch_names () {
local expl local expl
declare -a branch_names local -a branch_names=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/heads 2>/dev/null)"}#refs/heads/})
__git_flow_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 () { __git_flow_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

View File

@ -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]' \ '(- *)'{-v,--version}'[display version information and exit]' \
{-t,--traditional}'[use traditional greeting]' \ {-t,--traditional}'[use traditional greeting]' \
{-g,--greeting=}'[use TEXT as the greeting message]:TEXT' {-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

View File

@ -284,3 +284,11 @@ while (( $#state )); do
done done
return ret 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

View File

@ -84,3 +84,11 @@ _kitchen_instances() {
} }
_kitchen "$@" _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

View File

@ -154,3 +154,11 @@ case $state in
esac esac
return ret 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

View File

@ -126,8 +126,7 @@ _1st_arguments=(
'--version:Prints the Elixir version information' '--version:Prints the Elixir version information'
) )
__task_list () __task_list () {
{
local expl local expl
declare -a tasks declare -a tasks
@ -211,7 +210,6 @@ __task_list ()
} }
local expl local expl
local curcontext="$curcontext" state line local curcontext="$curcontext" state line
typeset -A opt_args typeset -A opt_args
@ -222,19 +220,23 @@ _arguments -C \
case $state in case $state in
(command) (command)
_describe -t commands "mix subcommand" _1st_arguments _describe -t commands "mix subcommand" _1st_arguments
return
;; ;;
(options) (options)
case $line[1] in case $line[1] in
(help) (help)
_arguments ':feature:__task_list' _arguments ':feature:__task_list'
return
;; ;;
(test|format|run) (test|format|run)
_arguments ':PATH:_files' _arguments ':PATH:_files'
return
;; ;;
esac esac
;; ;;
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

View File

@ -106,3 +106,11 @@ _describe 'command' instances
# Reference: # Reference:
# https://zsh.sourceforge.net/Doc/Release/Completion-System.html # https://zsh.sourceforge.net/Doc/Release/Completion-System.html
# https://github.com/zsh-users/zsh-completions/blob/master/zsh-completions-howto.org # 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

View File

@ -144,3 +144,11 @@ local options=(
) )
_arguments $options "*::func_name:($func_names)" _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

View File

@ -12,30 +12,31 @@
# * 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
@ -87,7 +88,7 @@ while true;do
(mon1) (mon1)
case $line[1] in case $line[1] in
(new | destroy) (new | destroy)
# descriptors=( ":: :_nft_mon_keywords" ":: :_nft_out_format") # descriptors=( ":: :_nft_mon_keywords" ":: :_nft_out_format")
descriptors=( ":: : _nft_mon_keywords") descriptors=( ":: : _nft_mon_keywords")
nextstate="mon1" nextstate="mon1"
;; ;;
@ -264,7 +265,7 @@ while true;do
"*:: :->$nextstate" \ "*:: :->$nextstate" \
&& return 0; && return 0;
done done
} # end _nft } # end _nft
_nft_subcommands(){ _nft_subcommands(){
@ -284,6 +285,7 @@ _nft_subcommands(){
) )
_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'

View File

@ -225,7 +225,7 @@ _openvpn3_command() {
_describe -t commands 'openvpn3 commands' openvpn3_cmds _describe -t commands 'openvpn3 commands' openvpn3_cmds
else else
local curcontext="$curcontext" local curcontext="$curcontext"
cmd="${${openvpn3_cmds[(r)$words[1]:*]%%:*}}" local cmd="${${openvpn3_cmds[(r)$words[1]:*]%%:*}}"
if (($#cmd)); then if (($#cmd)); then
if (( $+functions[_openvpn3_$cmd] )); then if (( $+functions[_openvpn3_$cmd] )); then
_openvpn3_$cmd _openvpn3_$cmd

View File

@ -121,10 +121,10 @@ _setcap_capabilities() {
_setcap "$@" _setcap "$@"
# Local variables: # Local Variables:
# mode: Shell-Script # mode: Shell-Script
# sh-indentation: 2 # sh-indentation: 2
# indent-tabs-mode: nil # indent-tabs-mode: nil
# sh-basic-offset: 2 # sh-basic-offset: 2
# End: # End:
# ex: sw=2 ts=2 et filetype=sh # vim: ft=zsh sw=2 ts=2 et

View File

@ -93,8 +93,8 @@ _tmuxp() {
&& ret=0 && ret=0
;; ;;
(shell) (shell)
local sessions="$(__tmux_sessions)" local sessions="$(__tmuxp_tmux_sessions)"
local windows="$(__tmux_windows)" local windows="$(__tmuxp_tmux_windows)"
_arguments \ _arguments \
'(- *)'{-h,--help}'[show help message and exit]' \ '(- *)'{-h,--help}'[show help message and exit]' \
'-S[pass-through for tmux -S]: :_files' \ '-S[pass-through for tmux -S]: :_files' \
@ -179,15 +179,13 @@ __tmuxp_import() {
esac esac
} }
__tmux_sessions () { __tmuxp_tmux_sessions() {
local tmux_sessions local tmux_sessions=($(_call_program tmux_sessions 'tmux ls -F "#{session_name}"'))
tmux_sessions=($(_call_program tmux_sessions 'tmux ls -F "#{session_name}"'))
echo $tmux_sessions echo $tmux_sessions
} }
__tmux_windows () { __tmuxp_tmux_windows() {
local tmux_windows local tmux_windows=($(_call_program tmux_sessions 'tmux ls -F "#{window_name}"'))
tmux_windows=($(_call_program tmux_sessions 'tmux ls -F "#{window_name}"'))
echo $tmux_windows echo $tmux_windows
} }

View File

@ -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. # 2: Complete interface with all .conf files in /etc/wireguard without the filename extension.
_arguments "1:mode:((${modes}))"\ _arguments "1:mode:((${modes}))"\
'2:interface:_path_files -W /etc/wireguard -g "*.conf(^/:r)"' '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