@@ -52,11 +52,15 @@ static void printCommandlineHelp() {
52
52
return ;
53
53
}
54
54
55
- static void badArgument (const char * arg ) {
56
- printf ("Bad argument: %s \n\n" , arg );
55
+ static void cliError (const char * prefix , const char * errorMsg ) {
56
+ printf ("%s%s \n\n" , prefix , errorMsg );
57
57
printCommandlineHelp ();
58
58
}
59
59
60
+ static void badArgument (const char * arg ) {
61
+ cliError ("Bad argument: " , arg );
62
+ }
63
+
60
64
boolean tryParseUint64 (char * str , uint64_t * num ) {
61
65
unsigned long long n ;
62
66
char buf [100 ];
@@ -195,20 +199,33 @@ int main(int argc, char *argv[])
195
199
}
196
200
197
201
if (strcmp (argv [i ], "--print-seed-catalog" ) == 0 ) {
202
+ uint64_t startingSeed , numberOfSeeds ;
203
+ int numberOfLevels ;
204
+
198
205
if (i + 3 < argc ) {
199
- uint64_t startingSeed , numberOfSeeds ;
200
- // Use converter for the type the next size up, because it returns signed
201
- unsigned int numberOfLevels = atol ( argv [i + 3 ]);
202
-
203
- if ( tryParseUint64 ( argv [ i + 1 ], & startingSeed ) && tryParseUint64 ( argv [ i + 2 ], & numberOfSeeds )
204
- && startingSeed > 0 && numberOfLevels <= 40 ) {
205
- printSeedCatalog ( startingSeed , numberOfSeeds , numberOfLevels , isCsvFormat );
206
- return 0 ;
206
+ numberOfLevels = atoi ( argv [ i + 3 ]) ;
207
+ if (! tryParseUint64 ( argv [ i + 1 ], & startingSeed )) {
208
+ cliError ( "Bad params for seed catalog, starting seed: " , argv [i + 1 ]);
209
+ return 1 ;
210
+ }
211
+ if (! tryParseUint64 ( argv [ i + 2 ], & numberOfSeeds ) ) {
212
+ cliError ( "Bad params for seed catalog, number of seeds: " , argv [ i + 2 ] );
213
+ return 1 ;
207
214
}
208
215
} else {
209
- printSeedCatalog (1 , 1000 , 5 , isCsvFormat );
210
- return 0 ;
216
+ startingSeed = 1 ;
217
+ numberOfSeeds = 1000 ;
218
+ numberOfLevels = 5 ;
219
+ }
220
+
221
+ int errorCode ;
222
+ char errorMessage [ERROR_MESSAGE_LENGTH ];
223
+
224
+ errorCode = printSeedCatalog (startingSeed , numberOfSeeds , numberOfLevels , isCsvFormat , errorMessage );
225
+ if (errorCode ) {
226
+ cliError ("Bad params for seed catalog, " , errorMessage );
211
227
}
228
+ return errorCode ;
212
229
}
213
230
214
231
if (strcmp (argv [i ], "-V" ) == 0 || strcmp (argv [i ], "--version" ) == 0 ) {
0 commit comments