aboutsummaryrefslogtreecommitdiffstats
path: root/src/_ufw
diff options
context:
space:
mode:
authorShohei YOSHIDA <syohex@gmail.com>2025-05-16 17:44:28 +0900
committerShohei YOSHIDA <syohex@gmail.com>2025-05-16 17:44:28 +0900
commitd1469c6e4f08ca70a391cb891f307f3568270e20 (patch)
treeb9b21e27c1450624d004ff1fa3a084eb2a6638a0 /src/_ufw
parentUpdate shallow-backup completion (diff)
downloadzsh-completions-d1469c6e4f08ca70a391cb891f307f3568270e20.tar
zsh-completions-d1469c6e4f08ca70a391cb891f307f3568270e20.tar.gz
zsh-completions-d1469c6e4f08ca70a391cb891f307f3568270e20.tar.bz2
zsh-completions-d1469c6e4f08ca70a391cb891f307f3568270e20.tar.lz
zsh-completions-d1469c6e4f08ca70a391cb891f307f3568270e20.tar.xz
zsh-completions-d1469c6e4f08ca70a391cb891f307f3568270e20.tar.zst
zsh-completions-d1469c6e4f08ca70a391cb891f307f3568270e20.zip
Update ufw completion
Diffstat (limited to 'src/_ufw')
-rw-r--r--src/_ufw184
1 files changed, 104 insertions, 80 deletions
diff --git a/src/_ufw b/src/_ufw
index 238ff1a..21639b1 100644
--- a/src/_ufw
+++ b/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"
- )
+ _describe -t params 'on/off' params
+ _describe -t additional 'level' additional
+}
- additional=(
- "low"
- "medium"
- "high"
- "full"
- )
+_ufw_delete() {
+ local rules complrules second
- _describe -t params 'on/off' params
- _describe -t additional 'level' additional
-}
+ second=$words[2]
+ if [ ! -z $second ]; then
+ return
+ fi
-_ufw_delete() {
- local rules complrules second
+ complrules=()
+ rules=("${(f)$(ufw status | tr -s ' ' | tail -n +5 | tr -s '\n')}")
- second=$words[2]
+ for ((i=1; i<=${#rules[@]}; i++)); do
+ complrules+=("$i:$rules[i]");
+ done
- if [ ! -z $second ]; then
- return
- fi
+ _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"
+ )
- complrules=()
- rules=("${(f)$(ufw status | tr -s ' ' | tail -n +5 | tr -s '\n')}")
+ _arguments \
+ "1: :{_describe 'command' subcmds}" \
+ && ret=0
+
+ return ret
+}
- for ((i=1; i<=${#rules[@]}; i++)); do
- complrules+=("$i:$rules[i]");
- done
+(( $+functions[_flutter_pub_token_subcommand] )) ||
+_flutter_pub_token_subcommand() {
+ local -a subcommands=(
- _describe -t complrules 'Rules' complrules
+ )
+ _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