components/zsh/Completion/Solaris/Command/_zoneadm
branchs11-update
changeset 3021 b9308977c65b
parent 3020 a14aae53a1c7
child 3023 90190872ae3e
equal deleted inserted replaced
3020:a14aae53a1c7 3021:b9308977c65b
     1 #compdef zoneadm
       
     2 # Synced with the S11U1 man page
       
     3 
       
     4 _zoneadm_bootargs() {
       
     5 	# This is a subset of the arguments to kernel(1M)
       
     6 	_arguments -A "-*" \
       
     7 		'-i[Alternate init]:path:_path_files' \
       
     8 		'-m[SMF options]:option:_values "SMF option" debug milestone= quiet verbose' \
       
     9 		'-s[Boot single user]'
       
    10 }
       
    11 
       
    12 _zoneadm() {
       
    13 	local context state line expl
       
    14 	typeset -A opt_args
       
    15 	local -a subcmds fields
       
    16 	local -a solaris_attach solaris_install
       
    17 	local -a solaris10_attach solaris10_install
       
    18 	local -a extended_create_options extended_destroy_options
       
    19 	local brand brand_args
       
    20 
       
    21 	subcmds=(
       
    22 		attach boot clone detach halt help install list mark move
       
    23 		ready reboot uninstall verify
       
    24 	)
       
    25 
       
    26 	extended_create_options=(
       
    27 		"force-zpool-import"
       
    28 		"force-zpool-create:ZFS pool: "
       
    29 		"force-zpool-create-all"
       
    30 	)
       
    31 
       
    32 	extended_destroy_options=(
       
    33 		"force-zpool-destroy:ZFS pool: "
       
    34 		"force-zpool-destroy-all"
       
    35 	)
       
    36 
       
    37 	solaris_attach=(
       
    38 		'(-d)-a[Path to archive]:path:_path_files'
       
    39 		'(-a)-d[Path to zonepath]:directory:_path_files -/'
       
    40 	)
       
    41 	solaris_install=(
       
    42 		- set1
       
    43 		'-c[Path to certificate]:path:_path_files'
       
    44 		'*-e[Additional package]:package:'
       
    45 		'-k[Path to key]:path:_path_files'
       
    46 		'-P[Publisher/URI mapping]:publisher:'
       
    47 		- set2
       
    48 		'(-d)-a[Path to archive]:path:_path_files'
       
    49 		'(-a)-d[Path to installed zone root]:directory:path_files -/'
       
    50 		'-p[Preserve system configuration]'
       
    51 		'-s[Install silently]'
       
    52 		'-u[Unconfigure after installation]'
       
    53 		'-v[Verbose]'
       
    54 	)
       
    55 
       
    56 	solaris10_attach=(
       
    57 		'(-d)-a[Path to archive]:path:_path_files'
       
    58 		'(-a)-d[Path to zonepath]:directory:_path_files -/'
       
    59 	)
       
    60 	solaris10_install=(
       
    61 		'(-d)-a[Path to archive]:path:_path_files'
       
    62 		'(-a)-d[Path to installed zone root]:directory:path_files -/'
       
    63 		'-p[Preserve system configuration]'
       
    64 		'-s[Install silently]'
       
    65 		'-u[Unconfigure after installation]'
       
    66 		'-v[Verbose]'
       
    67 	)
       
    68 
       
    69 	if [[ $service == "zoneadm" ]]; then
       
    70 		_arguments -C -A "-*" \
       
    71 			'-R[Alternate root]:alternate root:_path_files -/' \
       
    72 			'-u[Zone UUID]:zone UUID: ' \
       
    73 			'-z[Zone name]:zone name:_zones' \
       
    74 			'*::command:->subcmd' && return 0
       
    75 
       
    76 		if (( CURRENT == 1 )); then
       
    77 			_wanted commands expl "zoneadm subcommand" compadd -a subcmds
       
    78 			return
       
    79 		fi
       
    80 		service="$words[1]"
       
    81 		curcontext="${curcontext%:*}=$service:"
       
    82 	fi
       
    83 
       
    84 	case $service in
       
    85 	("boot")
       
    86 		# Completion of boot arguments after -- is kinda hacky.
       
    87 		_arguments -S -A "-*" \
       
    88 			'-w[Force writable root]' \
       
    89 			'-W[Boot in transient r/w mode]' \
       
    90 			'*:boot options:_zoneadm_bootargs'
       
    91 		;;
       
    92 
       
    93 	("clone")
       
    94 		_arguments -A "-*" \
       
    95 			'-m[Clone mode]:mode:_values "mode" copy' \
       
    96 			'-s[Source snapshot]:snapshot:_zfs_dataset -t snap' \
       
    97 			'-x[Extended options]:extended option:_values -w "extended option" $extended_create_options' \
       
    98 			':source zone:_zones'
       
    99 		;;
       
   100 
       
   101 	("attach")
       
   102 		if [[ -n $opt_args[-z] ]]; then
       
   103 			brand=${"${(@s,:,)$(zoneadm -z $opt_args[-z] list -p)}"[6]}
       
   104 			brand_args=${brand}_attach
       
   105 		fi
       
   106 		_arguments -A "-*" \
       
   107 			'-F[Force attach]' \
       
   108 			'-n[Path to zone manifest]:path to zone manifest:_path_files' \
       
   109 			'-u[Update on attach]' \
       
   110 			'-x[Extended options]:extended option:_values -w "extended option" $extended_create_options' \
       
   111 			${(P)brand_args}
       
   112 		;;
       
   113 
       
   114 	("detach")
       
   115 		_arguments -A "-*" \
       
   116 			'-n[Dry run]'
       
   117 		;;
       
   118 
       
   119 	("halt"|"ready"|"reboot"|"verify")
       
   120 		;;
       
   121 
       
   122 
       
   123 	("help")
       
   124 		_wanted commands expl "zoneadm subcommand" compadd -a subcmds
       
   125 		;;
       
   126 
       
   127 	("install")
       
   128 		if [[ -n $opt_args[-z] ]]; then
       
   129 			brand=${"${(@s,:,)$(zoneadm -z $opt_args[-z] list -p)}"[6]}
       
   130 			brand_args=${brand}_install
       
   131 		fi
       
   132 		_arguments -A "-*" \
       
   133 			'-x[Extended options]:extended option:_values -w "extended option" $extended_create_options' \
       
   134 			${(P)brand_args}
       
   135 		;;
       
   136 
       
   137 	("list")
       
   138 		_arguments -A "-*" \
       
   139 			'-c[Configured zones]' \
       
   140 			'-i[Installed zones]' \
       
   141 			'(-v)-p[Parsable output]' \
       
   142 			'(-p)-v[Verbose mode]'
       
   143 		;;
       
   144 
       
   145 	("mark")
       
   146 		_arguments -A "-*" \
       
   147 			':state:(incomplete unavailable)'
       
   148 		;;
       
   149 
       
   150 	("move")
       
   151 		_arguments -A "-*" \
       
   152 			':new zone path:_path_files -/'
       
   153 		;;
       
   154 
       
   155 	("uninstall")
       
   156 		_arguments -A "-*" \
       
   157 			'-F[Force]' \
       
   158 			'-x[Extended options]:extended option:_values -w "extended option" $extended_destroy_options'
       
   159 		;;
       
   160 	esac
       
   161 }
       
   162 
       
   163 _zoneadm "$@"