Merge pull request #1134 from zsh-users/update-completions

Update shallow-backup, ufw completions
This commit is contained in:
Shohei YOSHIDA 2025-05-17 21:42:55 +09:00 committed by GitHub
commit 99d000d880
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 206 additions and 178 deletions

View File

@ -42,6 +42,10 @@ _setcap() {
local curcontext=$curcontext state line expl ret=1 local curcontext=$curcontext state line expl ret=1
_arguments -C -s \ _arguments -C -s \
'-r[remove capability from file]' \
'--license[display the license info]' \
'-f[force setting even when the capability is invalid]' \
'-h[show help message and exit]' \
'-v[verify that the specified capabilities are currently associated with the file]' \ '-v[verify that the specified capabilities are currently associated with the file]' \
'-n[set the file capability for use only in a user namespace with this root user ID owner]:rootuid' \ '-n[set the file capability for use only in a user namespace with this root user ID owner]:rootuid' \
'-q[make the program less verbose in its output]' \ '-q[make the program less verbose in its output]' \

View File

@ -28,7 +28,7 @@
# Description # Description
# ----------- # -----------
# #
# Completion script for shallow-backup: https://github.com/alichtman/shallow-backup # Completion script for shallow-backup v6.4: https://github.com/alichtman/shallow-backup
# #
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Authors # Authors
@ -38,30 +38,30 @@
# #
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
_shallow-backup() { _shallow-backup() {
_arguments \ _arguments \
'(- 1 *)'{-h,--help}'[Show help and exit]' \ '(- 1 *)'{-h,--help}'[Show help and exit]' \
'(- 1 *)'{-v,--version}'[Print version]' \ '(- 1 *)'{-v,--version}'[Print version]' \
'--add-dot[Add a dotfile or dotfolder to config by path]:PATH:_files' \ '--add-dot[Add a dotfile or dotfolder to config by path]:PATH:_files' \
'--backup-all[Full back up]' \ '--backup-all[Full back up]' \
'--backup-configs[Back up app config files]' \ '--backup-configs[Back up app config files]' \
'--backup-dots[Back up dotfiles]' \ '--backup-dots[Back up dotfiles]' \
'--backup-fonts[Back up installed fonts]' \ '--backup-fonts[Back up installed fonts]' \
'--backup-packages[Back up package libraries]' \ '--backup-packages[Back up package libraries]' \
'--delete-config[Delete config file]' \ '--delete-config[Delete config file]' \
'--destroy-backup[Delete backup directory]' \ '--destroy-backup[Delete backup directory]' \
'--dry-run[Do not backup or reinstall any files, just give verbose output]' \ '--dry-run[Do not backup or reinstall any files, just give verbose output]' \
'--new-path[Input a new back up directory path]:PATH:_files -/' \ '--new-path[Input a new back up directory path]:PATH:_files -/' \
'--no-new-backup-path-prompt[Skip setting new back up directory path prompt]' \ '--no-new-backup-path-prompt[Skip setting new back up directory path prompt]' \
'--no-splash[Do not display splash screen]' \ '--no-splash[Do not display splash screen]' \
'--reinstall-all[Full reinstallation]' \ '--reinstall-all[Full reinstallation]' \
'--reinstall-configs[Reinstall configs]' \ '--reinstall-configs[Reinstall configs]' \
'--reinstall-dots[Reinstall dotfiles and dotfolders]' \ '--reinstall-dots[Reinstall dotfiles and dotfolders]' \
'--reinstall-fonts[Reinstall fonts]' \ '--reinstall-fonts[Reinstall fonts]' \
'--reinstall-packages[Reinstall packages]' \ '--reinstall-packages[Reinstall packages]' \
'--remote[Set remote URL for the git repo]':url \ '--remote[Set remote URL for the git repo]':url \
'--show[Display config file]' '--edit[Open config file in $EDITOR]' \
'--show[Display config file]'
} }
_shallow-backup _shallow-backup

View File

@ -35,7 +35,7 @@
# ------- # -------
# #
# * Bruno Michel (https://github.com/nono) # * Bruno Michel (https://github.com/nono)
# * Shoehi Yoshida (https://github.com/nono) # * Shohei Yoshida (https://github.com/nono)
# #
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@ -76,78 +76,78 @@ _showoff() {
'*:: :->args' \ '*:: :->args' \
&& ret=0 && ret=0
case $state in case $state in
(args) (args)
case $line[1] in case $line[1] in
(add|new) (add|new)
_arguments \ _arguments \
'(-d --dir)'{-d,--dir}='[Slide dir (where to put a new slide file)]:directory:_files -/' \ '(-d --dir)'{-d,--dir}='[Slide dir (where to put a new slide file)]:directory:_files -/' \
'(-n --name)'{-n,--name}='[Slide name (name of the new slide file)]:basename' \ '(-n --name)'{-n,--name}='[Slide name (name of the new slide file)]:basename' \
{-s,--source}='[Include code from the given file as the slide body]:file:_files' \ {-s,--source}='[Include code from the given file as the slide body]:file:_files' \
'(-t --style --type)'{-t,--style,--type}='[Slide Type/Style (default: title)]:style' \ '(-t --style --type)'{-t,--style,--type}='[Slide Type/Style (default: title)]:style' \
'(-u --nonumber)'{-u,--nonumber}"[Don't number the slide, use the given name verbatim]" \ '(-u --nonumber)'{-u,--nonumber}"[Don't number the slide, use the given name verbatim]" \
'1:title' && ret=0 '1:title' && ret=0
;; ;;
(create|init) (create|init)
_arguments \ _arguments \
'(-d --slidedir)'{-d,--slidedir}='[Sample slide directory name (default: one)]:arg' \ '(-d --slidedir)'{-d,--slidedir}='[Sample slide directory name (default: one)]:arg' \
'(-n --nosamples)'{-n,--nosamples}="[Don't create sample slides]" \ '(-n --nosamples)'{-n,--nosamples}="[Don't create sample slides]" \
'1:dir_name' && ret=0 '1:dir_name' && ret=0
;; ;;
(help) (help)
_arguments \ _arguments \
'-c[List commands one per line, to assist with shell completion]' \ '-c[List commands one per line, to assist with shell completion]' \
'1: :_showoff_help' && ret=0 '1: :_showoff_help' && ret=0
;; ;;
(heroku) (heroku)
_arguments \ _arguments \
'(-f --force)'{-f,--force}'[force overwrite of existing Gemfile, .gems and config.ru files if they exist]' \ '(-f --force)'{-f,--force}'[force overwrite of existing Gemfile, .gems and config.ru files if they exist]' \
'(-p --password)'{-p,--password}='[add password protection to your heroku site(default: none)]' \ '(-p --password)'{-p,--password}='[add password protection to your heroku site(default: none)]' \
'1:heroku_name' && ret=0 '1:heroku_name' && ret=0
;; ;;
(info) (info)
_arguments \ _arguments \
'(-f --file)'{-f,--file}='[alternate json filename]: :_files -g "*.json"' \ '(-f --file)'{-f,--file}='[alternate json filename]: :_files -g "*.json"' \
'(-j --json)'{-j,--json}'[render output as json]' \ '(-j --json)'{-j,--json}'[render output as json]' \
&& ret=0 && ret=0
;; ;;
(pdf|static) (pdf|static)
_arguments \ _arguments \
'(-f --file --pres_file)'{-f,--file,--pres_file}='[JSON file used to describe presentation(default: showoff.json)]: :_files -g "*.json"' \ '(-f --file --pres_file)'{-f,--file,--pres_file}='[JSON file used to describe presentation(default: showoff.json)]: :_files -g "*.json"' \
'(-l --lang --language --locale)'{-l,--lang,--language,--locale}'[Language code to generate(default: none)]' \ '(-l --lang --language --locale)'{-l,--lang,--language,--locale}'[Language code to generate(default: none)]' \
'1:name' \ '1:name' \
&& ret=0 && ret=0
;; ;;
(serve) (serve)
_arguments \ _arguments \
'(-S --standalone)'{-S,--standalone}'[Run in standalone mode with no audience interaction]' \ '(-S --standalone)'{-S,--standalone}'[Run in standalone mode with no audience interaction]' \
'(-f --file --pres_file)'{-f,--file,--pres_file}='[JSON file used to describe presentation(default: showoff.json)]: :_files -g "*.json"' \ '(-f --file --pres_file)'{-f,--file,--pres_file}='[JSON file used to describe presentation(default: showoff.json)]: :_files -g "*.json"' \
'--git_branch=[Branch of git repository to use(default: none)]:branch' \ '--git_branch=[Branch of git repository to use(default: none)]:branch' \
'--git_path=[Path of the presentation within the git repository(default: none)]:path' \ '--git_path=[Path of the presentation within the git repository(default: none)]:path' \
'(-h --host)'{-h,--host}='[Host or ip to run on(default: 0.0.0.0)]' \ '(-h --host)'{-h,--host}='[Host or IP to run on(default: 0.0.0.0)]' \
'--nocache[Disable content caching]'\ '--nocache[Disable content caching]'\
'--nosleep[Prevent the computer from sleeping during your presentation]' \ '--nosleep[Prevent the computer from sleeping during your presentation]' \
'(-p --port)'{-p,--port}='[Port on which to run(default: 9090)]' \ '(-p --port)'{-p,--port}='[Port on which to run(default: 9090)]' \
'(-r --review)'{-r,--review}'[Enable code review]'\ '(-r --review)'{-r,--review}'[Enable code review]'\
'(-s --ssl)'{-s,--ssl}'[Run via HTTPS]' \ '(-s --ssl)'{-s,--ssl}'[Run via HTTPS]' \
'--ssl_certificate=[Path to SSL certificate]: :_files' \ '--ssl_certificate=[Path to SSL certificate]: :_files' \
'--ssl_private_key=[Path to SSL private key]: :_files' \ '--ssl_private_key=[Path to SSL private key]: :_files' \
'(-u --url --git_url)'{-u,--url,--git_url}='[GIT URL to a repository containing the presentation]:url' \ '(-u --url --git_url)'{-u,--url,--git_url}='[GIT URL to a repository containing the presentation]:url' \
'(-v --verbose)'{-v,--verbose}'[Show verbose messaging]' \ '(-v --verbose)'{-v,--verbose}'[Show verbose messaging]' \
'(-x --execute --executecode)'{-x,--execute,--executecode}'[Enable remote code execution]' \ '(-x --execute --executecode)'{-x,--execute,--executecode}'[Enable remote code execution]' \
'1: :_files -/' && ret=0 '1: :_files -/' && ret=0
;; ;;
(skeleton|validate) (skeleton|validate)
_arguments \ _arguments \
'(-f --file)'{-f,--file}'=[alternate json filename(default: none)]: :_files -g "*.json"' \ '(-f --file)'{-f,--file}'=[alternate json filename(default: none)]: :_files -g "*.json"' \
&& ret=0 && ret=0
;; ;;
*) *)
(( ret )) && _message 'no more arguments' (( ret )) && _message 'no more arguments'
;; ;;
esac esac
;; ;;
esac esac
return ret return ret
} }

186
src/_ufw
View File

@ -28,7 +28,7 @@
# Description # Description
# ----------- # -----------
# #
# Completion script for The Uncomplicated Firewall (ufw). (https://launchpad.net/ufw). # Completion script for The Uncomplicated Firewall (ufw) v0.36.2. (https://launchpad.net/ufw).
# #
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Authors # Authors
@ -38,108 +38,132 @@
# #
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
_ufw_logging() { _ufw_logging() {
local params additional second
second=$words[2]
local params additional second if [ ! -z $second ]; then
second=$words[2] return
fi
if [ ! -z $second ]; then params=("on" "off")
return additional=("low" "medium" "high" "full")
fi
params=( _describe -t params 'on/off' params
"on" _describe -t additional 'level' additional
"off"
)
additional=(
"low"
"medium"
"high"
"full"
)
_describe -t params 'on/off' params
_describe -t additional 'level' additional
} }
_ufw_delete() { _ufw_delete() {
local rules complrules second local rules complrules second
second=$words[2] second=$words[2]
if [ ! -z $second ]; then if [ ! -z $second ]; then
return return
fi fi
complrules=() complrules=()
rules=("${(f)$(ufw status | tr -s ' ' | tail -n +5 | tr -s '\n')}") rules=("${(f)$(ufw status | tr -s ' ' | tail -n +5 | tr -s '\n')}")
for ((i=1; i<=${#rules[@]}; i++)); do for ((i=1; i<=${#rules[@]}; i++)); do
complrules+=("$i:$rules[i]"); complrules+=("$i:$rules[i]");
done done
_describe -t complrules 'Rules' complrules _describe -t complrules 'Rules' complrules
}
_ufw_app() {
local ret=1
local -a subcmds=(
"list:list application profiles"
"info:show information on profile"
"update:update profile"
"default:set default application profile"
)
_arguments \
"1: :{_describe 'command' subcmds}" \
&& ret=0
return ret
}
(( $+functions[_flutter_pub_token_subcommand] )) ||
_flutter_pub_token_subcommand() {
local -a subcommands=(
)
_describe -t subcommands 'subcommand' subcommands "$@"
} }
_ufw() { _ufw() {
local curcontext="$curcontext" ret=1 local curcontext="$curcontext" ret=1
local -a state line commands local -a state line commands
commands=( commands=(
"enable:enable the firewall" "enable:enable the firewall"
"disable:disable the firewall" "disable:disable the firewall"
"default:set default policy" "default:set default policy"
"logging:set logging level" "logging:set logging level"
"allow:add allow rule" "allow:add allow rule"
"deny:add deny rule" "deny:add deny rule"
"reject:add reject rule" "reject:add reject rule"
"limit:add limit rule" "limit:add limit rule"
"delete:delete rule" "delete:delete rule"
"insert:insert rule at position" "insert:insert rule at position"
"route:add route rule" "route:add route rule"
"reload:reload firewall" "reload:reload firewall"
"reset:reset firewall" "reset:reset firewall"
"status:show firewall status" "status:show firewall status"
"show:show firewall report" "show:show firewall report"
"version:display version information" "version:display version information"
"prepend:add rule before all of the same type" "prepend:add rule before all of the same type"
) "app:application profile command"
)
_arguments -C -s -S -n \ _arguments -C -s -S -n \
'(- 1 *)'--version"[display version information]: :->full" \ '(- 1 *)'--version"[display version information]: :->full" \
'(- 1 *)'{-h,--help}'[display usage information]: :->full' \ '(- 1 *)'{-h,--help}'[display usage information]: :->full' \
'(- 1 *)'--dry-run"[don't modify anything, just show the changes]: :->cmds" \ '(- 1 *)'--dry-run"[don't modify anything, just show the changes]: :->cmds" \
'1:cmd:->cmds' \ '1:cmd:->cmds' \
'*:: :->args' && ret=0 '*:: :->args' && ret=0
case "$state" in case "$state" in
(cmds) (cmds)
_describe -t commands 'commands' commands _describe -t commands 'commands' commands
;; ;;
(args) (args)
local cmd local cmd
cmd=$words[1] cmd=$words[1]
case "$cmd" in case "$cmd" in
(logging) (logging)
_ufw_logging && ret=0 _ufw_logging && ret=0
;; ;;
(delete) (delete)
_ufw_delete && ret=0 _ufw_delete && ret=0
;; ;;
(*) (app)
_default && ret=0 _ufw_app && ret=0
;; ;;
esac (*)
_default && ret=0
;;
esac
;; ;;
(*) (*)
;; ;;
esac esac
return ret return ret
} }
_ufw _ufw "$@"
# 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