remove utf8 garbage
[zfbsd.git] / _pw
bloba123d61b20df89f7e92895ca775b6f09ee64d865
1 #compdef pw
3 _pw() {
4   local tmp common_args user_cmn_args
5   common_args=(
6   "-V[Set the alternate location for /etc]:Alternate etc dir:_files -/"
7   '-C[Specify a different configuration file]:Configuration file:_files -g "*.conf"'
8   '-q[Suppress rrror messages]'
9   )
10   user_cmn_args=(
11   '-n[Specify the name]:name:'
12   '-u[Specify the uid]:uid:'
13   )
14   _arguments -s  \
15   '*::command:->commands' && ret=0
16   while [[ -n "$state" ]]; do
17     tmp="$state"
18     state=
19     case "$tmp" in
20       commands)
21       if (( CURRENT == 1 )); then
22         state=subcommands
23       else
24         case "$words[1]" in 
25           useradd)
26           ;;
27           userdel)
28           _arguments \
29           $common_args \
30           $user_cmn_args \
31           "-r[Remove the user's home directory]" \
32           "-Y[allow automatic updating of NIS database]" \
33           ":Name or uid:_users" 
34           ;;
35           usermod)
36           local shells
37           if [[ -r /etc/shells ]]; then
38             shells=( ${${(f)"$(</etc/shells)"}:#\#*} )
39           else
40             shells=( ${(M)commands:#*/(|[abckz]|tc|ba)sh} )
41           fi
43           _arguments \
44           $common_args \
45           "-Y[allow automatic updating of NIS database]" \
46           '-n[Specify the name]:name:' \
47           '-u[Specify the uid]:uid:' \
48           '-c[Modify the comment]:comment:' \
49           "-d[Modify the home directory location]:home dir:_directories -W /" \
50           "-e[Modify the expiration date]:date:" \
51           "-p[Modify the password expiration date]:date:" \
52           "-g[Modify the main group]:group:_groups" \
53           "-G[Modify supplementary groups]:groups:_groups -S," \
54           "-l[Modify the user name]:name:" \
55           "-m[Attempt to create the user's directory]" \
56           "-M[Create the user’s home directory with the specified mode]:mode:" \
57           "-k[Skeleton for the home directory creation]:skeleton dir:_directories -W /" \
58           "-w[sets the default method used to set passwords]:methods:((no\:disable\ login yes\:force\ the\ password\ to\ be\ the\ account\ name none\:force\ a\ blank\ password random\:generate\ a\ random\ password))" \
59           "-s[specify the user shell]:shell:( $shells /sbin/nologin )" \
60           "-L[Set the login class]:class:" \
61           "-N[output the result of the operation without updating the user databases]" \
62           "-P[outputs the account details in a more human readable form]" \
63           ":Name or uid:_users"
64           ;;
65           usershow)
66           _arguments \
67           $common_args \
68           '-n[Specify the name]:name:' \
69           '-u[Specify the uid]:uid:' \
70           "-F[forces pw to print the details of an account]" \
71           "-P[outputs the account details in a more human readable form]" \
72           "-7[show account details in v7 format]" \
73           "-a[lists all users currently on file]" \
74           ":Name|uid:_users"
76           ;;
77           (user|group)next)
78                 return 0
79           ;;
80           groupadd)
81           _arguments \
82           $common_args \
83           $user_cmn_args
84           ;;
85           groupdel)
86           _arguments \
87           $common_args \
88           $user_cmn_args
89           ;;
90           groupmod)
91           _arguments \
92           $common_args \
93           $user_cmn_args
94           ;;
95           groupshow)
96           _arguments \
97           $common_args \
98           $user_cmn_args
99           ;;
100           lock|unlock)
101           _arguments \
102           $common_args \
103           ":User to $words[1]:_users"
104           ;;
105           *)
106           _message 'command not found'
107           ;;
108         esac
109       fi
110       ;;
111       subcommands)
112       subcmds=(
113       'useradd[Add a user]'
114       'userdel[Delete a user]'
115       'usermod[Modify a user]'
116       'usershow[Show informations about a user]'
117       'usernext'
118       'groupdadd[Add a group]'
119       'groupdel[Delete a group]'
120       'groupmod[Modify a group]'
121       'groupshow[Show information about a group]'
122       'groupnext'
123       'lock[lock a user]'
124       'unlock[unlock a user]'
125       )
126       _values "pw command" $subcmds && return 0
127       ;;
128     esac
129   done
132 _pw "$@"