about summary refs log tree commit diff
path: root/Completion/Solaris/Command/_beadm
diff options
context:
space:
mode:
Diffstat (limited to 'Completion/Solaris/Command/_beadm')
-rw-r--r--Completion/Solaris/Command/_beadm135
1 files changed, 64 insertions, 71 deletions
diff --git a/Completion/Solaris/Command/_beadm b/Completion/Solaris/Command/_beadm
index 6e498bee3..8422653d8 100644
--- a/Completion/Solaris/Command/_beadm
+++ b/Completion/Solaris/Command/_beadm
@@ -1,76 +1,69 @@
 #compdef beadm
 
-_beadm() {
-	local context state line subcmds
-	typeset -A opt_args
+local cmd expl args
 
-	subcmds=( activate create destroy list mount rename unmount )
+if (( CURRENT == 2 )); then
+  _wanted subcommands expl 'subcommand' compadd \
+      activate create destroy list mount rename unmount
+  return
+fi
 
-	if [[ $service == "beadm" ]]; then
-		_arguments -C -A "-*" \
-			'*::command:->subcmd' && return 0
+cmd="$words[2]"
+curcontext="${curcontext%:*}-$cmd:"
+shift words
+(( CURRENT-- ))
 
-		if (( CURRENT == 1 )); then
-			_wanted commands expl 'beadm subcommand' compadd -a subcmds
-			return
-		fi
-		service="$words[1]"
-		curcontext="${curcontext%:*}=$service:"
-	fi
-
-	case $service in
-	(activate)
-		_arguments -A "-*" \
-			':BE name:_be_name'
-		;;
-
-	(create)
-		# TODO: Add support for -o, and for creating snapshots
-		_arguments -A "-*" \
-			'-a[Activate new BE]' \
-			'-d[Description]:' \
-			'-e[Base BE]:BE name or snapshot:_be_name -t all' \
-			'-p[Create new BE in specified ZFS pool]:ZFS pool:_zfs_pool' \
-			':new BE name:'
-		;;
-
-	(destroy)
-		_arguments -A "-*" \
-			'-f[Unmount BE if necessary]' \
-			"-F[Don't prompt for verification]" \
-			':BE or BE snapshot:_be_name'
-		;;
-
-	(list)
-		_arguments -A "-*" \
-			'-a[List subordinate filesystems and snapshots]' \
-			'-d[List subordinate filesystems]' \
-			'-s[List snapshots]' \
-			'-H[Parseable format]' \
-			':BE name:_be_name'
-		;;
-
-	(mount)
-		_arguments -A "-*" \
-			':BE name:_be_name' \
-			':mountpoint:_path_files -/'
-		;;
-
-	(rename)
-		_arguments -A "-*" \
-			':existing BE name:_be_name' \
-			':new BE name:'
-		;;
-
-	(unmount)
-		_arguments -A "-*" \
-			'-f[Force unmount]' \
-			':BE name:_be_name'
-		;;
-
-	(*)
-		_message "unknown beadm subcommand: $service"
-	esac
-}
-
-_beadm "$@"
+case $cmd in
+  activate)
+    _wanted boot-environs expl 'boot environment' _be_name
+  ;;
+  create)
+    [[ $OSTYPE = solaris* ]] && args=(
+      '-a[activate new BE]'
+      '-d[description]:description'
+      '*-o[property]:zfs property'
+      '-p[create new BE in specified zfs pool]:zfs pool:_zfs_pool'
+    )
+    _arguments -A "-*" $args \
+      '-e[base BE]:BE name or snapshot:_be_name -t all' \
+      ':new BE name:'
+  ;;
+  destroy)
+    [[ $OSTYPE = solaris* ]] && args=(
+      '-f[unmount BE if necessary]'
+    )
+    _arguments -A "-*" \
+      "-F[don't prompt for verification]" \
+      ':BE or BE snapshot:_be_name'
+  ;;
+  list)
+    if [[ $OSTYPE = solaris* ]]; then
+      args=( '-d[list subordinate filesystems]' )
+    elif [[ $OSTYPE = freebsd* ]]; then
+      args=( '-D[display space usage of boot environment]' )
+    fi
+    _arguments -A "-*" \
+      '-a[list subordinate filesystems and snapshots]' \
+      '-s[list snapshots]' \
+      '-H[parseable format]' \
+      ':boot environment:_be_name'
+  ;;
+  mount)
+    _arguments -A "-*" \
+      ':BE name:_be_name' \
+      ':mountpoint:_path_files -/'
+  ;;
+  rename)
+    _arguments -A "-*" \
+      ':existing boot environment name:_be_name' \
+      ':new boot environment:'
+  ;;
+  u(n|)mount)
+    _arguments -A "-*" \
+      '-f[force unmount]' \
+      ':boot environment:_be_name'
+  ;;
+  *)
+    _message "unknown beadm subcommand: $service"
+  ;;
+esac