1
0
mirror of https://github.com/sqlite/sqlite.git synced 2026-01-06 08:01:16 +03:00

Further improvements to the ".help" command in the CLI.

FossilOrigin-Name: edc3d18ecbda32d6a55de76ee7335342425c57d917e9b48814a7301a012263b2
This commit is contained in:
drh
2018-09-26 18:02:32 +00:00
parent 98aa2abc45
commit eb7f2a0fc5
3 changed files with 57 additions and 46 deletions

View File

@@ -1,5 +1,5 @@
C Begin\srevamping\sthe\s".help"\scommand\sin\sthe\scommand-line\sshell\sso\sthat\sit\ncan\saccept\san\sargument\sand\swill\sdo\sa\ssearch\sfor\scommands\sthat\smatch\sthat\nargument.
D 2018-09-26T16:53:51.572
C Further\simprovements\sto\sthe\s".help"\scommand\sin\sthe\sCLI.
D 2018-09-26T18:02:32.772
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F Makefile.in 01e95208a78b57d056131382c493c963518f36da4c42b12a97eb324401b3a334
@@ -503,7 +503,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384
F src/resolve.c bc8c79e56439b111e7d9415e44940951f7087e9466c3a9d664558ef0faf31073
F src/rowset.c d977b011993aaea002cab3e0bb2ce50cf346000dff94e944d547b989f4b1fe93
F src/select.c 1b7ade8fabb85ccd3369683a7951fda37b2843aa1e4ef1fa866b09596a8bfec3
F src/shell.c.in 03d87b063174919f97d18d7272b41e387667de7876dee24f97245cb50a6b54db
F src/shell.c.in 2162b1dc99b806298207c9c202aa7b49ac8553b8b1e73bb28cd80d5a1861df39
F src/sqlite.h.in 4b4c2f2daeeed4412ba9d81bc78092c69831fe6eda4f0ae5bf951da51a8dccec
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
F src/sqlite3ext.h 305adca1b5da4a33ce2db5bd236935768e951d5651bfe5560ed55cfcdbce6a63
@@ -1769,7 +1769,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P cbaf5b6c1b07b29b2c83fa01618de856d81cc1174769cb9770cb5c894cc87ace
R f78ccf48cad379f9ff8d08a24576cd4d
P 209afb8d06466536863b89a8acb9a1a18477a06331d8cce95fc6380e1666b6f5
R 2bbe28ad2c8e39198abb575c136c791e
U drh
Z ffa405c420bd31d67403441934b061ad
Z 46449abd20dff7d89e070088562c2521

View File

@@ -1 +1 @@
209afb8d06466536863b89a8acb9a1a18477a06331d8cce95fc6380e1666b6f5
edc3d18ecbda32d6a55de76ee7335342425c57d917e9b48814a7301a012263b2

View File

@@ -3378,12 +3378,15 @@ static const char *(azHelp[]) = {
".databases List names and files of attached databases",
".dbconfig ?op? ?val? List or change sqlite3_db_config() options",
".dbinfo ?DB? Show status information about the database",
".dump ?TABLE? ... Dump the database in an SQL text format",
" TABLE is LIKE pattern for the tables to dump",
".dump ?TABLE? ... Render all database content as SQL",
" Options:",
" --preserve-rowids Include ROWID values in the output",
" --newlines Allow unescaped newline characters in output",
" TABLE is LIKE pattern for the tables to dump",
".echo on|off Turn command echo on or off",
".eqp on|off|full Enable or disable automatic EXPLAIN QUERY PLAN",
".excel Display the output of next command in a spreadsheet",
".exit Exit this program",
".exit ?CODE? Exit this program with return-code CODE",
".expert EXPERIMENTAL. Suggest indexes for specified queries",
/* Because explain mode comes on automatically now, the ".explain" mode
** is removed from the help screen. It is still supported for legacy, however */
@@ -3445,12 +3448,34 @@ static const char *(azHelp[]) = {
".schema ?PATTERN? Show the CREATE statements matching PATTERN",
" Options:",
" --indent Try to pretty-print the schema",
".selftest ?--init? Run tests defined in the SELFTEST table",
".selftest ?OPTIONS? Run tests defined in the SELFTEST table",
" Options:",
" --init Create a new SELFTEST table",
" -v Verbose output",
".separator COL ?ROW? Change the column and row separators",
#if defined(SQLITE_ENABLE_SESSION)
".session CMD ... Create or control sessions",
".session ?NAME? CMD ... Create or control sessions",
" Subcommands:",
" attach TABLE Attach TABLE",
" changeset FILE Write a changeset into FILE",
" close Close one session",
" enable ?BOOLEAN? Set or query the enable bit",
" filter GLOB... Reject tables matching GLOBs",
" indirect ?BOOLEAN? Mark or query the indirect status",
" isempty Query whether the session is empty",
" list List currently open session names",
" open DB NAME Open a new session on DB",
" patchset FILE Write a patchset into FILE",
" If ?NAME? is omitted, the first defined session is used.",
#endif
".sha3sum ?OPTIONS...? Compute a SHA3 hash of database content",
".sha3sum ... Compute a SHA3 hash of database content",
" Options:",
" --schema Also hash the sqlite_master table",
" --sha3-224 Use the sha3-224 algorithm",
" --sha3-256 Use the sha3-256 algorithm. This is the default.",
" --sha3-384 Use the sha3-384 algorithm",
" --sha3-512 Use the sha3-512 algorithm",
" Any other argument is a LIKE pattern for tables to hash",
#ifndef SQLITE_NOHAVE_SYSTEM
".shell CMD ARGS... Run CMD ARGS... in a system shell",
#endif
@@ -3498,17 +3523,24 @@ static int showHelp(FILE *out, const char *zPattern){
for(i=0; i<ArraySize(azHelp); i++){
if( sqlite3_strglob(zPat, azHelp[i])==0 ){
utf8_printf(out, "%s\n", azHelp[i]);
while( i<ArraySize(azHelp)-1 && azHelp[i+1][0]!='.' ){
i++;
utf8_printf(out, "%s\n", azHelp[i]);
}
j = i+1;
n++;
}
}
sqlite3_free(zPat);
if( n ) return n;
/* Look for commands that contain zPattern anywhere */
if( n ){
if( n==1 ){
/* when zPattern is a prefix of exactly one command, then include the
** details of that command, which should begin at offset j */
while( j<ArraySize(azHelp)-1 && azHelp[j][0]!='.' ){
utf8_printf(out, "%s\n", azHelp[j]);
j++;
}
}
return n;
}
/* Look for commands that contain zPattern anywhere. Show the complete
** text of all commands that match. */
zPat = sqlite3_mprintf("%%%s%%", zPattern);
for(i=0; i<ArraySize(azHelp); i++){
if( azHelp[i][0]=='.' ) j = i;
@@ -3527,30 +3559,6 @@ static int showHelp(FILE *out, const char *zPattern){
return n;
}
#if defined(SQLITE_ENABLE_SESSION)
/*
** Print help information for the ".sessions" command
*/
void session_help(ShellState *p){
raw_printf(p->out,
".session ?NAME? SUBCOMMAND ?ARGS...?\n"
"If ?NAME? is omitted, the first defined session is used.\n"
"Subcommands:\n"
" attach TABLE Attach TABLE\n"
" changeset FILE Write a changeset into FILE\n"
" close Close one session\n"
" enable ?BOOLEAN? Set or query the enable bit\n"
" filter GLOB... Reject tables matching GLOBs\n"
" indirect ?BOOLEAN? Mark or query the indirect status\n"
" isempty Query whether the session is empty\n"
" list List currently open session names\n"
" open DB NAME Open a new session on DB\n"
" patchset FILE Write a patchset into FILE\n"
);
}
#endif
/* Forward reference */
static int process_input(ShellState *p, FILE *in);
@@ -5904,7 +5912,10 @@ static int do_meta_command(char *zLine, ShellState *p){
}else
if( c=='d' && n>=3 && strncmp(azArg[0], "dbconfig", n)==0 ){
static const struct DbConfigChoices {const char *zName; int op;} aDbConfig[] = {
static const struct DbConfigChoices {
const char *zName;
int op;
} aDbConfig[] = {
{ "enable_fkey", SQLITE_DBCONFIG_ENABLE_FKEY },
{ "enable_trigger", SQLITE_DBCONFIG_ENABLE_TRIGGER },
{ "fts3_tokenizer", SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER },
@@ -7162,7 +7173,7 @@ static int do_meta_command(char *zLine, ShellState *p){
}else
/* If no command name matches, show a syntax error */
session_syntax_error:
session_help(p);
showHelp(p->out, "session");
}else
#endif