Fossil SCM

When an ambiguous command prefix is entered, report all possible matches as part of the error message.

drh 2010-12-19 21:08 trunk
Commit 5ae54b39fd739dbc5f597b4638ebc6e7ec3a0216
1 file changed +11 -1
+11 -1
--- src/main.c
+++ src/main.c
@@ -251,13 +251,23 @@
251251
fprintf(stderr,"%s: unknown command: %s\n"
252252
"%s: use \"help\" for more information\n",
253253
argv[0], zCmdName, argv[0]);
254254
fossil_exit(1);
255255
}else if( rc==2 ){
256
+ int i, n;
257
+ Blob couldbe;
258
+ blob_zero(&couldbe);
259
+ n = strlen(zCmdName);
260
+ for(i=0; i<count(aCommand); i++){
261
+ if( memcmp(zCmdName, aCommand[i].zName, n)==0 ){
262
+ blob_appendf(&couldbe, " %s", aCommand[i].zName);
263
+ }
264
+ }
256265
fprintf(stderr,"%s: ambiguous command prefix: %s\n"
266
+ "%s: could be any of:%s\n"
257267
"%s: use \"help\" for more information\n",
258
- argv[0], zCmdName, argv[0]);
268
+ argv[0], zCmdName, argv[0], blob_str(&couldbe), argv[0]);
259269
fossil_exit(1);
260270
}
261271
aCommand[idx].xFunc();
262272
fossil_exit(0);
263273
/*NOT_REACHED*/
264274
--- src/main.c
+++ src/main.c
@@ -251,13 +251,23 @@
251 fprintf(stderr,"%s: unknown command: %s\n"
252 "%s: use \"help\" for more information\n",
253 argv[0], zCmdName, argv[0]);
254 fossil_exit(1);
255 }else if( rc==2 ){
 
 
 
 
 
 
 
 
 
256 fprintf(stderr,"%s: ambiguous command prefix: %s\n"
 
257 "%s: use \"help\" for more information\n",
258 argv[0], zCmdName, argv[0]);
259 fossil_exit(1);
260 }
261 aCommand[idx].xFunc();
262 fossil_exit(0);
263 /*NOT_REACHED*/
264
--- src/main.c
+++ src/main.c
@@ -251,13 +251,23 @@
251 fprintf(stderr,"%s: unknown command: %s\n"
252 "%s: use \"help\" for more information\n",
253 argv[0], zCmdName, argv[0]);
254 fossil_exit(1);
255 }else if( rc==2 ){
256 int i, n;
257 Blob couldbe;
258 blob_zero(&couldbe);
259 n = strlen(zCmdName);
260 for(i=0; i<count(aCommand); i++){
261 if( memcmp(zCmdName, aCommand[i].zName, n)==0 ){
262 blob_appendf(&couldbe, " %s", aCommand[i].zName);
263 }
264 }
265 fprintf(stderr,"%s: ambiguous command prefix: %s\n"
266 "%s: could be any of:%s\n"
267 "%s: use \"help\" for more information\n",
268 argv[0], zCmdName, argv[0], blob_str(&couldbe), argv[0]);
269 fossil_exit(1);
270 }
271 aCommand[idx].xFunc();
272 fossil_exit(0);
273 /*NOT_REACHED*/
274

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button