@@ -153,6 +153,8 @@ int main(int argc, char* argv[]) {
153
153
string script;
154
154
155
155
po::options_description shell_options (" options" );
156
+ po::options_description hidden_options (" Hidden options" );
157
+ po::options_description cmdline_options (" Command line options" );
156
158
po::positional_options_description positional_options;
157
159
158
160
shell_options.add_options ()
@@ -166,9 +168,16 @@ int main(int argc, char* argv[]) {
166
168
(" help,h" , " show this usage information" )
167
169
;
168
170
171
+ hidden_options.add_options ()
172
+ (" dbaddress" , po::value<string>(), " dbaddress" )
173
+ (" files" , po::value< vector<string> >(), " files" )
174
+ ;
175
+
169
176
positional_options.add (" dbaddress" , 1 );
170
177
positional_options.add (" files" , -1 );
171
178
179
+ cmdline_options.add (shell_options).add (hidden_options);
180
+
172
181
if (argc >= 2 ) {
173
182
po::variables_map params;
174
183
@@ -180,14 +189,14 @@ int main(int argc, char* argv[]) {
180
189
po::command_line_style::allow_sticky);
181
190
182
191
try {
183
- po::store (po::command_line_parser (argc, argv).options (shell_options ).
192
+ po::store (po::command_line_parser (argc, argv).options (cmdline_options ).
184
193
positional (positional_options).
185
194
style (command_line_style).run (), params);
186
195
po::notify (params);
187
196
} catch (po::error &e) {
188
197
cout << " ERROR: " << e.what () << endl << endl;
189
198
show_help_text (argv[0 ], shell_options);
190
- return 0 ;
199
+ return mongo::EXIT_BADOPTIONS ;
191
200
}
192
201
193
202
if (params.count (" shell" )) {
@@ -198,7 +207,7 @@ int main(int argc, char* argv[]) {
198
207
}
199
208
if (params.count (" help" )) {
200
209
show_help_text (argv[0 ], shell_options);
201
- return 0 ;
210
+ return mongo::EXIT_CLEAN ;
202
211
}
203
212
204
213
if (params.count (" files" )) {
@@ -213,14 +222,14 @@ int main(int argc, char* argv[]) {
213
222
* - it contains no '.' after the last appearance of '\' or '/'
214
223
* - it doesn't end in '.js' and it doesn't specify a path to an existing file */
215
224
if (params.count (" dbaddress" )) {
216
- string dbaddress = params[" dbaddress" ].as < vector< string> >()[ 0 ] ;
225
+ string dbaddress = params[" dbaddress" ].as <string>() ;
217
226
if (nodb) {
218
227
files.insert (files.begin (), dbaddress);
219
228
} else {
220
229
string basename = dbaddress.substr (dbaddress.find_last_of (" /\\ " ) + 1 );
221
230
path p (dbaddress);
222
- if (! basename.find_first_of (' .' ) ||
223
- (! basename.find (" .js" , basename.size () - 3 ) && !boost::filesystem::exists (p))) {
231
+ if (basename.find_first_of (' .' ) == string::npos ||
232
+ (basename.find (" .js" , basename.size () - 3 ) == string::npos && !boost::filesystem::exists (p))) {
224
233
url = dbaddress;
225
234
} else {
226
235
files.insert (files.begin (), dbaddress);
0 commit comments