Merge pull request #1134 from zsh-users/update-completions
Update shallow-backup, ufw completions
This commit is contained in:
		
						commit
						99d000d880
					
				|  | @ -42,6 +42,10 @@ _setcap() { | |||
|   local curcontext=$curcontext state line expl ret=1 | ||||
| 
 | ||||
|   _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]' \ | ||||
|     '-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]' \ | ||||
|  |  | |||
|  | @ -28,7 +28,7 @@ | |||
| # 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 | ||||
|  | @ -38,30 +38,30 @@ | |||
| # | ||||
| # ------------------------------------------------------------------------------ | ||||
| 
 | ||||
| 
 | ||||
| _shallow-backup() { | ||||
|     _arguments \ | ||||
|       '(- 1 *)'{-h,--help}'[Show help and exit]' \ | ||||
|       '(- 1 *)'{-v,--version}'[Print version]' \ | ||||
|       '--add-dot[Add a dotfile or dotfolder to config by path]:PATH:_files' \ | ||||
|       '--backup-all[Full back up]' \ | ||||
|       '--backup-configs[Back up app config files]' \ | ||||
|       '--backup-dots[Back up dotfiles]' \ | ||||
|       '--backup-fonts[Back up installed fonts]' \ | ||||
|       '--backup-packages[Back up package libraries]' \ | ||||
|       '--delete-config[Delete config file]' \ | ||||
|       '--destroy-backup[Delete backup directory]' \ | ||||
|       '--dry-run[Do not backup or reinstall any files, just give verbose output]' \ | ||||
|       '--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-splash[Do not display splash screen]' \ | ||||
|       '--reinstall-all[Full reinstallation]' \ | ||||
|       '--reinstall-configs[Reinstall configs]' \ | ||||
|       '--reinstall-dots[Reinstall dotfiles and dotfolders]' \ | ||||
|       '--reinstall-fonts[Reinstall fonts]' \ | ||||
|       '--reinstall-packages[Reinstall packages]' \ | ||||
|       '--remote[Set remote URL for the git repo]':url \ | ||||
|       '--show[Display config file]' | ||||
|   _arguments \ | ||||
|     '(- 1 *)'{-h,--help}'[Show help and exit]' \ | ||||
|     '(- 1 *)'{-v,--version}'[Print version]' \ | ||||
|     '--add-dot[Add a dotfile or dotfolder to config by path]:PATH:_files' \ | ||||
|     '--backup-all[Full back up]' \ | ||||
|     '--backup-configs[Back up app config files]' \ | ||||
|     '--backup-dots[Back up dotfiles]' \ | ||||
|     '--backup-fonts[Back up installed fonts]' \ | ||||
|     '--backup-packages[Back up package libraries]' \ | ||||
|     '--delete-config[Delete config file]' \ | ||||
|     '--destroy-backup[Delete backup directory]' \ | ||||
|     '--dry-run[Do not backup or reinstall any files, just give verbose output]' \ | ||||
|     '--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-splash[Do not display splash screen]' \ | ||||
|     '--reinstall-all[Full reinstallation]' \ | ||||
|     '--reinstall-configs[Reinstall configs]' \ | ||||
|     '--reinstall-dots[Reinstall dotfiles and dotfolders]' \ | ||||
|     '--reinstall-fonts[Reinstall fonts]' \ | ||||
|     '--reinstall-packages[Reinstall packages]' \ | ||||
|     '--remote[Set remote URL for the git repo]':url \ | ||||
|     '--edit[Open config file in $EDITOR]' \ | ||||
|     '--show[Display config file]' | ||||
| } | ||||
| 
 | ||||
| _shallow-backup | ||||
|  |  | |||
							
								
								
									
										146
									
								
								src/_showoff
								
								
								
								
							
							
						
						
									
										146
									
								
								src/_showoff
								
								
								
								
							|  | @ -35,7 +35,7 @@ | |||
| # ------- | ||||
| # | ||||
| #  * Bruno Michel (https://github.com/nono) | ||||
| #  * Shoehi Yoshida (https://github.com/nono) | ||||
| #  * Shohei Yoshida (https://github.com/nono) | ||||
| # | ||||
| # ------------------------------------------------------------------------------ | ||||
| 
 | ||||
|  | @ -76,78 +76,78 @@ _showoff() { | |||
|     '*:: :->args' \ | ||||
|       && ret=0 | ||||
| 
 | ||||
|     case $state in | ||||
|       (args) | ||||
|         case $line[1] in | ||||
|           (add|new) | ||||
|             _arguments \ | ||||
|               '(-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' \ | ||||
|               {-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' \ | ||||
|               '(-u --nonumber)'{-u,--nonumber}"[Don't number the slide, use the given name verbatim]" \ | ||||
|               '1:title' && ret=0 | ||||
|             ;; | ||||
|           (create|init) | ||||
|             _arguments \ | ||||
|               '(-d --slidedir)'{-d,--slidedir}='[Sample slide directory name (default: one)]:arg' \ | ||||
|               '(-n --nosamples)'{-n,--nosamples}="[Don't create sample slides]" \ | ||||
|               '1:dir_name' && ret=0 | ||||
|             ;; | ||||
|           (help) | ||||
|             _arguments \ | ||||
|               '-c[List commands one per line, to assist with shell completion]' \ | ||||
|               '1: :_showoff_help' && ret=0 | ||||
|             ;; | ||||
|           (heroku) | ||||
|             _arguments \ | ||||
|               '(-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)]' \ | ||||
|               '1:heroku_name' && ret=0 | ||||
|             ;; | ||||
|           (info) | ||||
|             _arguments \ | ||||
|               '(-f --file)'{-f,--file}='[alternate json filename]: :_files -g "*.json"' \ | ||||
|               '(-j --json)'{-j,--json}'[render output as json]' \ | ||||
|               && ret=0 | ||||
|             ;; | ||||
|           (pdf|static) | ||||
|             _arguments \ | ||||
|               '(-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)]' \ | ||||
|               '1:name' \ | ||||
|               && ret=0 | ||||
|             ;; | ||||
|           (serve) | ||||
|             _arguments \ | ||||
|               '(-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"' \ | ||||
|               '--git_branch=[Branch of git repository to use(default: none)]:branch' \ | ||||
|               '--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)]' \ | ||||
|               '--nocache[Disable content caching]'\ | ||||
|               '--nosleep[Prevent the computer from sleeping during your presentation]' \ | ||||
|               '(-p --port)'{-p,--port}='[Port on which to run(default: 9090)]' \ | ||||
|               '(-r --review)'{-r,--review}'[Enable code review]'\ | ||||
|               '(-s --ssl)'{-s,--ssl}'[Run via HTTPS]' \ | ||||
|               '--ssl_certificate=[Path to SSL certificate]: :_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' \ | ||||
|               '(-v --verbose)'{-v,--verbose}'[Show verbose messaging]' \ | ||||
|               '(-x --execute --executecode)'{-x,--execute,--executecode}'[Enable remote code execution]' \ | ||||
|               '1: :_files -/' && ret=0 | ||||
|             ;; | ||||
|           (skeleton|validate) | ||||
|             _arguments \ | ||||
|               '(-f --file)'{-f,--file}'=[alternate json filename(default: none)]: :_files -g "*.json"' \ | ||||
|               && ret=0 | ||||
|             ;; | ||||
|           *) | ||||
|             (( ret )) && _message 'no more arguments' | ||||
|             ;; | ||||
|         esac | ||||
|         ;; | ||||
|     esac | ||||
|   case $state in | ||||
|     (args) | ||||
|       case $line[1] in | ||||
|         (add|new) | ||||
|           _arguments \ | ||||
|             '(-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' \ | ||||
|             {-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' \ | ||||
|             '(-u --nonumber)'{-u,--nonumber}"[Don't number the slide, use the given name verbatim]" \ | ||||
|             '1:title' && ret=0 | ||||
|           ;; | ||||
|         (create|init) | ||||
|           _arguments \ | ||||
|             '(-d --slidedir)'{-d,--slidedir}='[Sample slide directory name (default: one)]:arg' \ | ||||
|             '(-n --nosamples)'{-n,--nosamples}="[Don't create sample slides]" \ | ||||
|             '1:dir_name' && ret=0 | ||||
|           ;; | ||||
|         (help) | ||||
|           _arguments \ | ||||
|             '-c[List commands one per line, to assist with shell completion]' \ | ||||
|             '1: :_showoff_help' && ret=0 | ||||
|           ;; | ||||
|         (heroku) | ||||
|           _arguments \ | ||||
|             '(-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)]' \ | ||||
|             '1:heroku_name' && ret=0 | ||||
|           ;; | ||||
|         (info) | ||||
|           _arguments \ | ||||
|             '(-f --file)'{-f,--file}='[alternate json filename]: :_files -g "*.json"' \ | ||||
|             '(-j --json)'{-j,--json}'[render output as json]' \ | ||||
|             && ret=0 | ||||
|           ;; | ||||
|         (pdf|static) | ||||
|           _arguments \ | ||||
|             '(-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)]' \ | ||||
|             '1:name' \ | ||||
|             && ret=0 | ||||
|           ;; | ||||
|         (serve) | ||||
|           _arguments \ | ||||
|             '(-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"' \ | ||||
|             '--git_branch=[Branch of git repository to use(default: none)]:branch' \ | ||||
|             '--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)]' \ | ||||
|             '--nocache[Disable content caching]'\ | ||||
|             '--nosleep[Prevent the computer from sleeping during your presentation]' \ | ||||
|             '(-p --port)'{-p,--port}='[Port on which to run(default: 9090)]' \ | ||||
|             '(-r --review)'{-r,--review}'[Enable code review]'\ | ||||
|             '(-s --ssl)'{-s,--ssl}'[Run via HTTPS]' \ | ||||
|             '--ssl_certificate=[Path to SSL certificate]: :_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' \ | ||||
|             '(-v --verbose)'{-v,--verbose}'[Show verbose messaging]' \ | ||||
|             '(-x --execute --executecode)'{-x,--execute,--executecode}'[Enable remote code execution]' \ | ||||
|             '1: :_files -/' && ret=0 | ||||
|           ;; | ||||
|         (skeleton|validate) | ||||
|           _arguments \ | ||||
|             '(-f --file)'{-f,--file}'=[alternate json filename(default: none)]: :_files -g "*.json"' \ | ||||
|             && ret=0 | ||||
|           ;; | ||||
|         *) | ||||
|           (( ret )) && _message 'no more arguments' | ||||
|           ;; | ||||
|       esac | ||||
|       ;; | ||||
|   esac | ||||
| 
 | ||||
|   return ret | ||||
| } | ||||
|  |  | |||
							
								
								
									
										186
									
								
								src/_ufw
								
								
								
								
							
							
						
						
									
										186
									
								
								src/_ufw
								
								
								
								
							|  | @ -28,7 +28,7 @@ | |||
| # 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 | ||||
|  | @ -38,108 +38,132 @@ | |||
| # | ||||
| # ------------------------------------------------------------------------------ | ||||
| 
 | ||||
| 
 | ||||
| _ufw_logging() { | ||||
|   local params additional second | ||||
|   second=$words[2] | ||||
| 
 | ||||
|     local params additional second | ||||
|     second=$words[2] | ||||
|   if [ ! -z $second ]; then | ||||
|     return | ||||
|   fi | ||||
| 
 | ||||
|     if [ ! -z $second ]; then | ||||
|         return | ||||
|     fi | ||||
|   params=("on" "off") | ||||
|   additional=("low" "medium" "high" "full") | ||||
| 
 | ||||
|     params=( | ||||
|       "on" | ||||
|       "off" | ||||
|     ) | ||||
| 
 | ||||
|     additional=( | ||||
|       "low" | ||||
|       "medium" | ||||
|       "high" | ||||
|       "full" | ||||
|     ) | ||||
| 
 | ||||
|     _describe -t params 'on/off' params | ||||
|     _describe -t additional 'level' additional | ||||
|   _describe -t params 'on/off' params | ||||
|   _describe -t additional 'level' additional | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| _ufw_delete() { | ||||
|     local rules complrules second | ||||
|   local rules complrules second | ||||
| 
 | ||||
|     second=$words[2] | ||||
|   second=$words[2] | ||||
| 
 | ||||
|     if [ ! -z $second ]; then | ||||
|         return | ||||
|     fi | ||||
|   if [ ! -z $second ]; then | ||||
|     return | ||||
|   fi | ||||
| 
 | ||||
|     complrules=() | ||||
|     rules=("${(f)$(ufw status | tr -s ' ' | tail -n +5 | tr -s '\n')}") | ||||
|   complrules=() | ||||
|   rules=("${(f)$(ufw status | tr -s ' ' | tail -n +5 | tr -s '\n')}") | ||||
| 
 | ||||
|     for ((i=1; i<=${#rules[@]}; i++)); do | ||||
|         complrules+=("$i:$rules[i]"); | ||||
|     done | ||||
|   for ((i=1; i<=${#rules[@]}; i++)); do | ||||
|     complrules+=("$i:$rules[i]"); | ||||
|   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() { | ||||
|     local curcontext="$curcontext" ret=1 | ||||
|     local -a state line commands | ||||
|   local curcontext="$curcontext" ret=1 | ||||
|   local -a state line commands | ||||
| 
 | ||||
|     commands=( | ||||
|       "enable:enable the firewall" | ||||
|       "disable:disable the firewall" | ||||
|       "default:set default policy" | ||||
|       "logging:set logging level" | ||||
|       "allow:add allow rule" | ||||
|       "deny:add deny rule" | ||||
|       "reject:add reject rule" | ||||
|       "limit:add limit rule" | ||||
|       "delete:delete rule" | ||||
|       "insert:insert rule at position" | ||||
|       "route:add route rule" | ||||
|       "reload:reload firewall" | ||||
|       "reset:reset firewall" | ||||
|       "status:show firewall status" | ||||
|       "show:show firewall report" | ||||
|       "version:display version information" | ||||
|       "prepend:add rule before all of the same type" | ||||
|     ) | ||||
|   commands=( | ||||
|     "enable:enable the firewall" | ||||
|     "disable:disable the firewall" | ||||
|     "default:set default policy" | ||||
|     "logging:set logging level" | ||||
|     "allow:add allow rule" | ||||
|     "deny:add deny rule" | ||||
|     "reject:add reject rule" | ||||
|     "limit:add limit rule" | ||||
|     "delete:delete rule" | ||||
|     "insert:insert rule at position" | ||||
|     "route:add route rule" | ||||
|     "reload:reload firewall" | ||||
|     "reset:reset firewall" | ||||
|     "status:show firewall status" | ||||
|     "show:show firewall report" | ||||
|     "version:display version information" | ||||
|     "prepend:add rule before all of the same type" | ||||
|     "app:application profile command" | ||||
|   ) | ||||
| 
 | ||||
|     _arguments -C -s -S -n \ | ||||
|         '(- 1 *)'--version"[display version information]: :->full" \ | ||||
|         '(- 1 *)'{-h,--help}'[display usage information]: :->full' \ | ||||
|         '(- 1 *)'--dry-run"[don't modify anything, just show the changes]: :->cmds" \ | ||||
|         '1:cmd:->cmds' \ | ||||
|         '*:: :->args' && ret=0 | ||||
|   _arguments -C -s -S -n \ | ||||
|     '(- 1 *)'--version"[display version information]: :->full" \ | ||||
|     '(- 1 *)'{-h,--help}'[display usage information]: :->full' \ | ||||
|     '(- 1 *)'--dry-run"[don't modify anything, just show the changes]: :->cmds" \ | ||||
|     '1:cmd:->cmds' \ | ||||
|     '*:: :->args' && ret=0 | ||||
| 
 | ||||
|     case "$state" in | ||||
|       (cmds) | ||||
|           _describe -t commands 'commands' commands | ||||
|   case "$state" in | ||||
|     (cmds) | ||||
|       _describe -t commands 'commands' commands | ||||
|       ;; | ||||
|       (args) | ||||
|          local cmd | ||||
|          cmd=$words[1] | ||||
|          case "$cmd" in | ||||
|              (logging) | ||||
|                  _ufw_logging && ret=0 | ||||
|              ;; | ||||
|              (delete) | ||||
|                  _ufw_delete && ret=0 | ||||
|              ;; | ||||
|              (*) | ||||
|                  _default && ret=0 | ||||
|              ;; | ||||
|          esac | ||||
|     (args) | ||||
|       local cmd | ||||
|       cmd=$words[1] | ||||
|       case "$cmd" in | ||||
|         (logging) | ||||
|           _ufw_logging && ret=0 | ||||
|           ;; | ||||
|         (delete) | ||||
|           _ufw_delete && ret=0 | ||||
|           ;; | ||||
|         (app) | ||||
|           _ufw_app && ret=0 | ||||
|           ;; | ||||
|         (*) | ||||
|           _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 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue