Fossil SCM
If the SUBCOMMAND argument to "fossil help" does not match a subcommand, then try using it as a search pattern.
Commit
4ee254ec4b73e55bd0f11a09490ac141931ce3942d3d4414c1e3d2cf33c2c928
Parent
baeffb9d31ad63b…
1 file changed
+30
-4
+30
-4
| --- src/dispatch.c | ||
| +++ src/dispatch.c | ||
| @@ -1096,13 +1096,34 @@ | ||
| 1096 | 1096 | } |
| 1097 | 1097 | break; |
| 1098 | 1098 | } |
| 1099 | 1099 | } |
| 1100 | 1100 | 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 | + } | |
| 1102 | 1124 | return n; |
| 1103 | - return 0; | |
| 1104 | 1125 | } |
| 1105 | 1126 | |
| 1106 | 1127 | /* |
| 1107 | 1128 | ** Input z[] is help text for a command zTopic. Write into pOut all lines of |
| 1108 | 1129 | ** z[] that show the command-line syntax for that command. Lines written |
| @@ -1237,15 +1258,20 @@ | ||
| 1237 | 1258 | } |
| 1238 | 1259 | |
| 1239 | 1260 | /* |
| 1240 | 1261 | ** COMMAND: help |
| 1241 | 1262 | ** |
| 1242 | -** Usage: %fossil help [OPTIONS] [TOPIC] [SUBCOMMAND] | |
| 1263 | +** Usage: %fossil help [OPTIONS] [TOPIC] [SUBCOMMAND|PATTERN] | |
| 1243 | 1264 | ** |
| 1244 | 1265 | ** Display information on how to use TOPIC, which may be a command, webpage, or |
| 1245 | 1266 | ** 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. | |
| 1247 | 1273 | ** |
| 1248 | 1274 | ** The following options can be used when TOPIC is omitted: |
| 1249 | 1275 | ** |
| 1250 | 1276 | ** -a|--all List both common and auxiliary commands |
| 1251 | 1277 | ** -e|--everything List all help on all topics |
| 1252 | 1278 |
| --- 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 |