components/zsh/Completion/Solaris/Command/_fmadm
changeset 429 02007d525e89
equal deleted inserted replaced
428:c1840af5fbf5 429:02007d525e89
       
     1 #compdef fmadm
       
     2 # Synced with the Nevada build 168 man page
       
     3 
       
     4 _fm_modules() {
       
     5 	compadd "$@" - $(fmadm config 2> /dev/null | awk 'NR == 1 {continue} {print $1}')
       
     6 }
       
     7 
       
     8 _fm_faulted_fmris() {
       
     9 	compadd "$@" - $(fmadm faulty -r 2> /dev/null | awk '{print $1}')
       
    10 }
       
    11 
       
    12 _fm_faulted_uuids() {
       
    13 	compadd "$@" - $(fmadm faulty -s 2> /dev/null | tail +4 | awk '{print $4}')
       
    14 }
       
    15 
       
    16 _fm_faulted_labels() {
       
    17 	local q='"'
       
    18 	compadd "$@" - $(fmadm faulty -f 2> /dev/null | while read line; do
       
    19 		if [[ $line == "----"* ]]; then
       
    20 			read line
       
    21 			if [[ $line == '"'* ]]; then
       
    22 				print ${${line[(r)$q,(rn:2:)$q]}[2,-2]}
       
    23 			fi
       
    24 		fi
       
    25 	done)
       
    26 }
       
    27 
       
    28 _fmadm() {
       
    29 	local context state line expl
       
    30 	local -A opt_args
       
    31 	local -a subcmds
       
    32 
       
    33 	# TODO: lookup-alias and remove-alias need completion based on the
       
    34 	# output of list-alias, but I have no examples of that output.
       
    35 
       
    36 	subcmds=(
       
    37 		"acquit" "config" "faulty" "flush" "load" "unload"
       
    38 		"repaired" "replaced" "reset" "rotate"
       
    39 		"add-alias" "remove-alias" "lookup-alias" "list-alias" "sync-alias"
       
    40 	)
       
    41 
       
    42 	if [[ $service == "fmadm" ]]; then
       
    43 		_arguments -C -A "-*" \
       
    44 			'-q[Quite mode]' \
       
    45 			'*::command:->subcmd' && return 0
       
    46 
       
    47 		if (( CURRENT == 1 )); then
       
    48 			_wanted commands expl "fmadm subcommand" compadd -a subcmds
       
    49 			return
       
    50 		fi
       
    51 		service="$words[1]"
       
    52 		curcontext="${curcontext%:*}=$service:"
       
    53 	fi
       
    54 
       
    55 	case $service in
       
    56 	("acquit")
       
    57 		_alternative \
       
    58 			"fmadm-acquit-label:label:_fm_faulted_labels" \
       
    59 			"fmadm-acquit-uuid:uuid:_fm_faulted_uuids" \
       
    60 			"fmadm-acquit-fmri:fmri:_fm_faulted_fmris"
       
    61 		;;
       
    62 
       
    63 	("config")
       
    64 		;;
       
    65 
       
    66 	("faulty")
       
    67 		_arguments -A "-*" \
       
    68 			'-a[Display all faults]' \
       
    69 			'-f[Display faulty FRUs]' \
       
    70 			'-g[Group faults]' \
       
    71 			'-i[Display persistent cache IDs]' \
       
    72 			'-n[Limit output to n entries]:number:' \
       
    73 			'-p[Page output]' \
       
    74 			'-r[Display resources]' \
       
    75 			'-s[Display one-line summaries]' \
       
    76 			'-u[Only display fault with given uuid]:uuid:_fm_faulted_uuids' \
       
    77 			'-v[Display full output]'
       
    78 		;;
       
    79 
       
    80 	("flush")
       
    81 		_fm_faulted_fmris
       
    82 		;;
       
    83 
       
    84 	("load")
       
    85 		_path_files -g "/*"
       
    86 		;;
       
    87 
       
    88 	("unload")
       
    89 		_fm_modules
       
    90 		;;
       
    91 
       
    92 	("repaired"|"replaced")
       
    93 		_alternative \
       
    94 			"fmadm-acquit-label:label:_fm_faulted_labels" \
       
    95 			"fmadm-acquit-fmri:fmri:_fm_faulted_fmris"
       
    96 		;;
       
    97 
       
    98 	("reset")
       
    99 		_arguments -A "-*" \
       
   100 			'-s[Reset named SERD]:serd:' \
       
   101 			':module:_fm_modules'
       
   102 		;;
       
   103 
       
   104 	("rotate")
       
   105 		_values "logfile" "errlog" "fltlog" "infolog" "infolog_hival"
       
   106 		;;
       
   107 
       
   108 	esac
       
   109 }
       
   110 
       
   111 _fmadm "$@"