Fossil SCM

If the SUBCOMMAND argument to "fossil help" does not match a subcommand, then try using it as a search pattern.

drh 2025-02-28 18:41 trunk
Commit 4ee254ec4b73e55bd0f11a09490ac141931ce3942d3d4414c1e3d2cf33c2c928
1 file changed +30 -4
+30 -4
--- src/dispatch.c
+++ src/dispatch.c
@@ -1096,13 +1096,34 @@
10961096
}
10971097
break;
10981098
}
10991099
}
11001100
fossil_free(zGlob);
1101
- if( n ) blob_trim(pOut);
1101
+ if( n ){
1102
+ blob_trim(pOut);
1103
+ blob_reset(&in);
1104
+ return n;
1105
+ }
1106
+
1107
+ /* If no subtop name zSubtopic if found, try again for any LIKE
1108
+ ** pattern match of zSubtopic.
1109
+ */
1110
+ blob_rewind(&in);
1111
+ if( zSubtopic[0]=='/' && zSubtopic[1]!=0 ) zSubtopic++;
1112
+ zGlob = mprintf("%%%s%%", zSubtopic);
1113
+ while( blob_line(&in, &line) ){
1114
+ if( sqlite3_strlike(zGlob, blob_str(&line),0)==0 ){
1115
+ blob_appendb(pOut, &line);
1116
+ n++;
1117
+ }
1118
+ }
1119
+ fossil_free(zGlob);
1120
+ blob_reset(&in);
1121
+ if( n ){
1122
+ blob_trim(pOut);
1123
+ }
11021124
return n;
1103
- return 0;
11041125
}
11051126
11061127
/*
11071128
** Input z[] is help text for a command zTopic. Write into pOut all lines of
11081129
** z[] that show the command-line syntax for that command. Lines written
@@ -1237,15 +1258,20 @@
12371258
}
12381259
12391260
/*
12401261
** COMMAND: help
12411262
**
1242
-** Usage: %fossil help [OPTIONS] [TOPIC] [SUBCOMMAND]
1263
+** Usage: %fossil help [OPTIONS] [TOPIC] [SUBCOMMAND|PATTERN]
12431264
**
12441265
** Display information on how to use TOPIC, which may be a command, webpage, or
12451266
** setting. Webpage names begin with "/". If TOPIC is omitted, a list of
1246
-** topics is returned.
1267
+** topics is returned. If there is an extra argument after TOPIC it is either
1268
+** the name of a subcommand, in which case only the help text for that one
1269
+** subcommand is show, or it is a LIKE pattern to search for, in which case all
1270
+** lines of text that match that pattern are returned. If the search pattern
1271
+** starts with "-", prepend "/" so that it will not be interpreted as an
1272
+** option to the help command itself.
12471273
**
12481274
** The following options can be used when TOPIC is omitted:
12491275
**
12501276
** -a|--all List both common and auxiliary commands
12511277
** -e|--everything List all help on all topics
12521278
--- src/dispatch.c
+++ src/dispatch.c
@@ -1096,13 +1096,34 @@
1096 }
1097 break;
1098 }
1099 }
1100 fossil_free(zGlob);
1101 if( n ) blob_trim(pOut);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1102 return n;
1103 return 0;
1104 }
1105
1106 /*
1107 ** Input z[] is help text for a command zTopic. Write into pOut all lines of
1108 ** z[] that show the command-line syntax for that command. Lines written
@@ -1237,15 +1258,20 @@
1237 }
1238
1239 /*
1240 ** COMMAND: help
1241 **
1242 ** Usage: %fossil help [OPTIONS] [TOPIC] [SUBCOMMAND]
1243 **
1244 ** Display information on how to use TOPIC, which may be a command, webpage, or
1245 ** setting. Webpage names begin with "/". If TOPIC is omitted, a list of
1246 ** topics is returned.
 
 
 
 
 
1247 **
1248 ** The following options can be used when TOPIC is omitted:
1249 **
1250 ** -a|--all List both common and auxiliary commands
1251 ** -e|--everything List all help on all topics
1252
--- src/dispatch.c
+++ src/dispatch.c
@@ -1096,13 +1096,34 @@
1096 }
1097 break;
1098 }
1099 }
1100 fossil_free(zGlob);
1101 if( n ){
1102 blob_trim(pOut);
1103 blob_reset(&in);
1104 return n;
1105 }
1106
1107 /* If no subtop name zSubtopic if found, try again for any LIKE
1108 ** pattern match of zSubtopic.
1109 */
1110 blob_rewind(&in);
1111 if( zSubtopic[0]=='/' && zSubtopic[1]!=0 ) zSubtopic++;
1112 zGlob = mprintf("%%%s%%", zSubtopic);
1113 while( blob_line(&in, &line) ){
1114 if( sqlite3_strlike(zGlob, blob_str(&line),0)==0 ){
1115 blob_appendb(pOut, &line);
1116 n++;
1117 }
1118 }
1119 fossil_free(zGlob);
1120 blob_reset(&in);
1121 if( n ){
1122 blob_trim(pOut);
1123 }
1124 return n;
 
1125 }
1126
1127 /*
1128 ** Input z[] is help text for a command zTopic. Write into pOut all lines of
1129 ** z[] that show the command-line syntax for that command. Lines written
@@ -1237,15 +1258,20 @@
1258 }
1259
1260 /*
1261 ** COMMAND: help
1262 **
1263 ** Usage: %fossil help [OPTIONS] [TOPIC] [SUBCOMMAND|PATTERN]
1264 **
1265 ** Display information on how to use TOPIC, which may be a command, webpage, or
1266 ** setting. Webpage names begin with "/". If TOPIC is omitted, a list of
1267 ** topics is returned. If there is an extra argument after TOPIC it is either
1268 ** the name of a subcommand, in which case only the help text for that one
1269 ** subcommand is show, or it is a LIKE pattern to search for, in which case all
1270 ** lines of text that match that pattern are returned. If the search pattern
1271 ** starts with "-", prepend "/" so that it will not be interpreted as an
1272 ** option to the help command itself.
1273 **
1274 ** The following options can be used when TOPIC is omitted:
1275 **
1276 ** -a|--all List both common and auxiliary commands
1277 ** -e|--everything List all help on all topics
1278

Keyboard Shortcuts

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