2828main (int argc ,char * argv [])
2929{
3030static struct option long_options []= {
31- {"host" ,required_argument ,NULL ,'h' },
32- {"port" ,required_argument ,NULL ,'p' },
33- {"username" ,required_argument ,NULL ,'U' },
34- {"role" ,required_argument ,NULL ,'g' },
35- {"no-password" ,no_argument ,NULL ,'w' },
36- {"password" ,no_argument ,NULL ,'W' },
37- {"echo" ,no_argument ,NULL ,'e' },
31+ {"connection-limit" ,required_argument ,NULL ,'c' },
3832{"createdb" ,no_argument ,NULL ,'d' },
3933{"no-createdb" ,no_argument ,NULL ,'D' },
40- {"superuser " ,no_argument ,NULL ,'s ' },
41- {"no-superuser " ,no_argument ,NULL ,'S ' },
42- {"createrole " ,no_argument ,NULL ,'r ' },
43- {"no-createrole " ,no_argument ,NULL ,'R ' },
34+ {"echo " ,no_argument ,NULL ,'e ' },
35+ {"encrypted " ,no_argument ,NULL ,'E ' },
36+ {"role " ,required_argument ,NULL ,'g ' },
37+ {"host " ,required_argument ,NULL ,'h ' },
4438{"inherit" ,no_argument ,NULL ,'i' },
4539{"no-inherit" ,no_argument ,NULL ,'I' },
4640{"login" ,no_argument ,NULL ,'l' },
4741{"no-login" ,no_argument ,NULL ,'L' },
42+ {"port" ,required_argument ,NULL ,'p' },
43+ {"pwprompt" ,no_argument ,NULL ,'P' },
44+ {"createrole" ,no_argument ,NULL ,'r' },
45+ {"no-createrole" ,no_argument ,NULL ,'R' },
46+ {"superuser" ,no_argument ,NULL ,'s' },
47+ {"no-superuser" ,no_argument ,NULL ,'S' },
48+ {"username" ,required_argument ,NULL ,'U' },
49+ {"no-password" ,no_argument ,NULL ,'w' },
50+ {"password" ,no_argument ,NULL ,'W' },
4851{"replication" ,no_argument ,NULL ,1 },
4952{"no-replication" ,no_argument ,NULL ,2 },
5053{"interactive" ,no_argument ,NULL ,3 },
51- {"connection-limit" ,required_argument ,NULL ,'c' },
52- {"pwprompt" ,no_argument ,NULL ,'P' },
53- {"encrypted" ,no_argument ,NULL ,'E' },
5454{NULL ,0 ,NULL ,0 }
5555};
5656
@@ -89,49 +89,33 @@ main(int argc, char *argv[])
8989
9090handle_help_version_opts (argc ,argv ,"createuser" ,help );
9191
92- while ((c = getopt_long (argc ,argv ,"h:p:U:g:wWedDsSrRiIlLc:PE " ,
92+ while ((c = getopt_long (argc ,argv ,"c:dDeEg:h:iIlLp:PrRsSU:wW " ,
9393long_options ,& optindex ))!= -1 )
9494{
9595switch (c )
9696{
97- case 'h' :
98- host = pg_strdup (optarg );
99- break ;
100- case 'p' :
101- port = pg_strdup (optarg );
102- break ;
103- case 'U' :
104- username = pg_strdup (optarg );
105- break ;
106- case 'g' :
107- simple_string_list_append (& roles ,optarg );
108- break ;
109- case 'w' :
110- prompt_password = TRI_NO ;
111- break ;
112- case 'W' :
113- prompt_password = TRI_YES ;
114- break ;
115- case 'e' :
116- echo = true;
97+ case 'c' :
98+ if (!option_parse_int (optarg ,"-c/--connection-limit" ,
99+ -1 ,INT_MAX ,& conn_limit ))
100+ exit (1 );
117101break ;
118102case 'd' :
119103createdb = TRI_YES ;
120104break ;
121105case 'D' :
122106createdb = TRI_NO ;
123107break ;
124- case 's ' :
125- superuser = TRI_YES ;
108+ case 'e ' :
109+ echo = true ;
126110break ;
127- case 'S ' :
128- superuser = TRI_NO ;
111+ case 'E ' :
112+ /* no-op, accepted for backward compatibility */
129113break ;
130- case 'r ' :
131- createrole = TRI_YES ;
114+ case 'g ' :
115+ simple_string_list_append ( & roles , optarg ) ;
132116break ;
133- case 'R ' :
134- createrole = TRI_NO ;
117+ case 'h ' :
118+ host = pg_strdup ( optarg ) ;
135119break ;
136120case 'i' :
137121inherit = TRI_YES ;
@@ -145,16 +129,32 @@ main(int argc, char *argv[])
145129case 'L' :
146130login = TRI_NO ;
147131break ;
148- case 'c' :
149- if (!option_parse_int (optarg ,"-c/--connection-limit" ,
150- -1 ,INT_MAX ,& conn_limit ))
151- exit (1 );
132+ case 'p' :
133+ port = pg_strdup (optarg );
152134break ;
153135case 'P' :
154136pwprompt = true;
155137break ;
156- case 'E' :
157- /* no-op, accepted for backward compatibility */
138+ case 'r' :
139+ createrole = TRI_YES ;
140+ break ;
141+ case 'R' :
142+ createrole = TRI_NO ;
143+ break ;
144+ case 's' :
145+ superuser = TRI_YES ;
146+ break ;
147+ case 'S' :
148+ superuser = TRI_NO ;
149+ break ;
150+ case 'U' :
151+ username = pg_strdup (optarg );
152+ break ;
153+ case 'w' :
154+ prompt_password = TRI_NO ;
155+ break ;
156+ case 'W' :
157+ prompt_password = TRI_YES ;
158158break ;
159159case 1 :
160160replication = TRI_YES ;