Fossil SCM
Allow --help anywhere on the command-line as an alternative way to get "help" for a command.
Commit
a00888f666373812fd1a0417805d830e0c06d3e3
Parent
b1cbae5de44ab85…
1 file changed
+14
-2
+14
-2
| --- src/main.c | ||
| +++ src/main.c | ||
| @@ -242,11 +242,23 @@ | ||
| 242 | 242 | g.fQuiet = find_option("quiet", 0, 0)!=0; |
| 243 | 243 | g.fSqlTrace = find_option("sqltrace", 0, 0)!=0; |
| 244 | 244 | g.fSqlPrint = find_option("sqlprint", 0, 0)!=0; |
| 245 | 245 | g.fHttpTrace = find_option("httptrace", 0, 0)!=0; |
| 246 | 246 | g.zLogin = find_option("user", "U", 1); |
| 247 | - zCmdName = argv[1]; | |
| 247 | + if( find_option("help",0,0)!=0 ){ | |
| 248 | + /* --help anywhere on the command line is translated into | |
| 249 | + ** "fossil help argv[1] argv[2]..." */ | |
| 250 | + int i; | |
| 251 | + char **zNewArgv = fossil_malloc( sizeof(char*)*(g.argc+2) ); | |
| 252 | + for(i=1; i<g.argc; i++) zNewArgv[i+1] = argv[i]; | |
| 253 | + zNewArgv[i+1] = 0; | |
| 254 | + zNewArgv[0] = argv[0]; | |
| 255 | + zNewArgv[1] = "help"; | |
| 256 | + g.argc++; | |
| 257 | + g.argv = zNewArgv; | |
| 258 | + } | |
| 259 | + zCmdName = g.argv[1]; | |
| 248 | 260 | } |
| 249 | 261 | rc = name_search(zCmdName, aCommand, count(aCommand), &idx); |
| 250 | 262 | if( rc==1 ){ |
| 251 | 263 | fprintf(stderr,"%s: unknown command: %s\n" |
| 252 | 264 | "%s: use \"help\" for more information\n", |
| @@ -519,11 +531,11 @@ | ||
| 519 | 531 | int i; |
| 520 | 532 | int nLong; |
| 521 | 533 | const char *zReturn = 0; |
| 522 | 534 | assert( hasArg==0 || hasArg==1 ); |
| 523 | 535 | nLong = strlen(zLong); |
| 524 | - for(i=2; i<g.argc; i++){ | |
| 536 | + for(i=1; i<g.argc; i++){ | |
| 525 | 537 | char *z; |
| 526 | 538 | if (i+hasArg >= g.argc) break; |
| 527 | 539 | z = g.argv[i]; |
| 528 | 540 | if( z[0]!='-' ) continue; |
| 529 | 541 | z++; |
| 530 | 542 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -242,11 +242,23 @@ | |
| 242 | g.fQuiet = find_option("quiet", 0, 0)!=0; |
| 243 | g.fSqlTrace = find_option("sqltrace", 0, 0)!=0; |
| 244 | g.fSqlPrint = find_option("sqlprint", 0, 0)!=0; |
| 245 | g.fHttpTrace = find_option("httptrace", 0, 0)!=0; |
| 246 | g.zLogin = find_option("user", "U", 1); |
| 247 | zCmdName = argv[1]; |
| 248 | } |
| 249 | rc = name_search(zCmdName, aCommand, count(aCommand), &idx); |
| 250 | if( rc==1 ){ |
| 251 | fprintf(stderr,"%s: unknown command: %s\n" |
| 252 | "%s: use \"help\" for more information\n", |
| @@ -519,11 +531,11 @@ | |
| 519 | int i; |
| 520 | int nLong; |
| 521 | const char *zReturn = 0; |
| 522 | assert( hasArg==0 || hasArg==1 ); |
| 523 | nLong = strlen(zLong); |
| 524 | for(i=2; i<g.argc; i++){ |
| 525 | char *z; |
| 526 | if (i+hasArg >= g.argc) break; |
| 527 | z = g.argv[i]; |
| 528 | if( z[0]!='-' ) continue; |
| 529 | z++; |
| 530 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -242,11 +242,23 @@ | |
| 242 | g.fQuiet = find_option("quiet", 0, 0)!=0; |
| 243 | g.fSqlTrace = find_option("sqltrace", 0, 0)!=0; |
| 244 | g.fSqlPrint = find_option("sqlprint", 0, 0)!=0; |
| 245 | g.fHttpTrace = find_option("httptrace", 0, 0)!=0; |
| 246 | g.zLogin = find_option("user", "U", 1); |
| 247 | if( find_option("help",0,0)!=0 ){ |
| 248 | /* --help anywhere on the command line is translated into |
| 249 | ** "fossil help argv[1] argv[2]..." */ |
| 250 | int i; |
| 251 | char **zNewArgv = fossil_malloc( sizeof(char*)*(g.argc+2) ); |
| 252 | for(i=1; i<g.argc; i++) zNewArgv[i+1] = argv[i]; |
| 253 | zNewArgv[i+1] = 0; |
| 254 | zNewArgv[0] = argv[0]; |
| 255 | zNewArgv[1] = "help"; |
| 256 | g.argc++; |
| 257 | g.argv = zNewArgv; |
| 258 | } |
| 259 | zCmdName = g.argv[1]; |
| 260 | } |
| 261 | rc = name_search(zCmdName, aCommand, count(aCommand), &idx); |
| 262 | if( rc==1 ){ |
| 263 | fprintf(stderr,"%s: unknown command: %s\n" |
| 264 | "%s: use \"help\" for more information\n", |
| @@ -519,11 +531,11 @@ | |
| 531 | int i; |
| 532 | int nLong; |
| 533 | const char *zReturn = 0; |
| 534 | assert( hasArg==0 || hasArg==1 ); |
| 535 | nLong = strlen(zLong); |
| 536 | for(i=1; i<g.argc; i++){ |
| 537 | char *z; |
| 538 | if (i+hasArg >= g.argc) break; |
| 539 | z = g.argv[i]; |
| 540 | if( z[0]!='-' ) continue; |
| 541 | z++; |
| 542 |