# define setTextMode(X,Y)
#endif
+static const char *(azHelp[]);
/* True if the timer is enabled */
static int enableTimer = 0;
return rc;
}
-/*
-** Text of help messages.
-**
-** The help text for each individual command begins with a line that starts
-** with ".". Subsequent lines are supplimental information.
-**
-** There must be two or more spaces between the end of the command and the
-** start of the description of what that command does.
-*/
-static const char *(azHelp[]) = {
-#if defined(SQLITE_HAVE_ZLIB) && !defined(SQLITE_OMIT_VIRTUALTABLE)
- ".archive ... Manage SQL archives",
- " Each command must have exactly one of the following options:",
- " -c, --create Create a new archive",
- " -u, --update Add or update files with changed mtime",
- " -i, --insert Like -u but always add even if unchanged",
- " -t, --list List contents of archive",
- " -x, --extract Extract files from archive",
- " Optional arguments:",
- " -v, --verbose Print each filename as it is processed",
- " -f FILE, --file FILE Use archive FILE (default is current db)",
- " -a FILE, --append FILE Open FILE using the apndvfs VFS",
- " -C DIR, --directory DIR Read/extract files from directory DIR",
- " -n, --dryrun Show the SQL that would have occurred",
- " Examples:",
- " .ar -cf ARCHIVE foo bar # Create ARCHIVE from files foo and bar",
- " .ar -tf ARCHIVE # List members of ARCHIVE",
- " .ar -xvf ARCHIVE # Verbosely extract files from ARCHIVE",
- " See also:",
- " http://sqlite.org/cli.html#sqlite_archive_support",
-#endif
-#ifndef SQLITE_OMIT_AUTHORIZATION
- ".auth ON|OFF Show authorizer callbacks",
-#endif
- ".backup ?DB? FILE Backup DB (default \"main\") to FILE",
- " --append Use the appendvfs",
- " --async Write to FILE without journal and fsync()",
- ".bail on|off Stop after hitting an error. Default OFF",
- ".binary on|off Turn binary output on or off. Default OFF",
- ".cd DIRECTORY Change the working directory to DIRECTORY",
- ".changes on|off Show number of rows changed by SQL",
- ".check GLOB Fail if output since .testcase does not match",
- ".clone NEWDB Clone data into NEWDB from the existing database",
- ".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 ?OBJECTS? Render database content as SQL",
- " Options:",
- " --data-only Output only INSERT statements",
- " --newlines Allow unescaped newline characters in output",
- " --nosys Omit system tables (ex: \"sqlite_stat1\")",
- " --preserve-rowids Include ROWID values in the output",
- " OBJECTS is a LIKE pattern for tables, indexes, triggers or views to dump",
- " Additional LIKE patterns can be given in subsequent arguments",
- ".echo on|off Turn command echo on or off",
- ".eqp on|off|full|... Enable or disable automatic EXPLAIN QUERY PLAN",
- " Other Modes:",
-#ifdef SQLITE_DEBUG
- " test Show raw EXPLAIN QUERY PLAN output",
- " trace Like \"full\" but enable \"PRAGMA vdbe_trace\"",
-#endif
- " trigger Like \"full\" but also show trigger bytecode",
- ".excel Display the output of next command in spreadsheet",
- " --bom Put a UTF8 byte-order mark on intermediate file",
- ".exit ?CODE? Exit this program with return-code CODE",
- ".expert EXPERIMENTAL. Suggest indexes for queries",
- ".explain ?on|off|auto? Change the EXPLAIN formatting mode. Default: auto",
- ".filectrl CMD ... Run various sqlite3_file_control() operations",
- " --schema SCHEMA Use SCHEMA instead of \"main\"",
- " --help Show CMD details",
- ".fullschema ?--indent? Show schema and the content of sqlite_stat tables",
- ".headers on|off Turn display of headers on or off",
- ".help ?-all? ?PATTERN? Show help text for PATTERN",
- ".import FILE TABLE Import data from FILE into TABLE",
- " Options:",
- " --ascii Use \\037 and \\036 as column and row separators",
- " --csv Use , and \\n as column and row separators",
- " --skip N Skip the first N rows of input",
- " -v \"Verbose\" - increase auxiliary output",
- " Notes:",
- " * If TABLE does not exist, it is created. The first row of input",
- " determines the column names.",
- " * If neither --csv or --ascii are used, the input mode is derived",
- " from the \".mode\" output mode",
- " * If FILE begins with \"|\" then it is a command that generates the",
- " input text.",
-#ifndef SQLITE_OMIT_TEST_CONTROL
- ".imposter INDEX TABLE Create imposter table TABLE on index INDEX",
-#endif
- ".indexes ?TABLE? Show names of indexes",
- " If TABLE is specified, only show indexes for",
- " tables matching TABLE using the LIKE operator.",
-#ifdef SQLITE_ENABLE_IOTRACE
- ".iotrace FILE Enable I/O diagnostic logging to FILE",
-#endif
- ".limit ?LIMIT? ?VAL? Display or change the value of an SQLITE_LIMIT",
- ".lint OPTIONS Report potential schema issues.",
- " Options:",
- " fkey-indexes Find missing foreign key indexes",
-#ifndef SQLITE_OMIT_LOAD_EXTENSION
- ".load FILE ?ENTRY? Load an extension library",
-#endif
- ".log FILE|off Turn logging on or off. FILE can be stderr/stdout",
- ".mode MODE ?TABLE? Set output mode",
- " MODE is one of:",
- " ascii Columns/rows delimited by 0x1F and 0x1E",
- " box Tables using unicode box-drawing characters",
- " csv Comma-separated values",
- " column Output in columns. (See .width)",
- " html HTML <table> code",
- " insert SQL insert statements for TABLE",
- " json Results in a JSON array",
- " line One value per line",
- " list Values delimited by \"|\"",
- " markdown Markdown table format",
- " quote Escape answers as for SQL",
- " table ASCII-art table",
- " tabs Tab-separated values",
- " tcl TCL list elements",
- ".nullvalue STRING Use STRING in place of NULL values",
- ".once ?OPTIONS? ?FILE? Output for the next SQL command only to FILE",
- " If FILE begins with '|' then open as a pipe",
- " --bom Put a UTF8 byte-order mark at the beginning",
- " -e Send output to the system text editor",
- " -x Send output as CSV to a spreadsheet (same as \".excel\")",
-#ifdef SQLITE_DEBUG
- ".oom ?--repeat M? ?N? Simulate an OOM error on the N-th allocation",
-#endif
- ".open ?OPTIONS? ?FILE? Close existing database and reopen FILE",
- " Options:",
- " --append Use appendvfs to append database to the end of FILE",
-#ifndef SQLITE_OMIT_DESERIALIZE
- " --deserialize Load into memory using sqlite3_deserialize()",
- " --hexdb Load the output of \"dbtotxt\" as an in-memory db",
- " --maxsize N Maximum size for --hexdb or --deserialized database",
-#endif
- " --new Initialize FILE to an empty database",
- " --nofollow Do not follow symbolic links",
- " --readonly Open FILE readonly",
- " --zip FILE is a ZIP archive",
- ".output ?FILE? Send output to FILE or stdout if FILE is omitted",
- " If FILE begins with '|' then open it as a pipe.",
- " Options:",
- " --bom Prefix output with a UTF8 byte-order mark",
- " -e Send output to the system text editor",
- " -x Send output as CSV to a spreadsheet",
- ".parameter CMD ... Manage SQL parameter bindings",
- " clear Erase all bindings",
- " init Initialize the TEMP table that holds bindings",
- " list List the current parameter bindings",
- " set PARAMETER VALUE Given SQL parameter PARAMETER a value of VALUE",
- " PARAMETER should start with one of: $ : @ ?",
- " unset PARAMETER Remove PARAMETER from the binding table",
- ".print STRING... Print literal STRING",
-#ifndef SQLITE_OMIT_PROGRESS_CALLBACK
- ".progress N Invoke progress handler after every N opcodes",
- " --limit N Interrupt after N progress callbacks",
- " --once Do no more than one progress interrupt",
- " --quiet|-q No output except at interrupts",
- " --reset Reset the count for each input and interrupt",
-#endif
- ".prompt MAIN CONTINUE Replace the standard prompts",
- ".quit Exit this program",
- ".read FILE Read input from FILE",
-#if !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_ENABLE_DBPAGE_VTAB)
- ".recover Recover as much data as possible from corrupt db.",
- " --freelist-corrupt Assume the freelist is corrupt",
- " --recovery-db NAME Store recovery metadata in database file NAME",
- " --lost-and-found TABLE Alternative name for the lost-and-found table",
- " --no-rowids Do not attempt to recover rowid values",
- " that are not also INTEGER PRIMARY KEYs",
-#endif
- ".restore ?DB? FILE Restore content of DB (default \"main\") from FILE",
- ".save FILE Write in-memory database into FILE",
- ".scanstats on|off Turn sqlite3_stmt_scanstatus() metrics on or off",
- ".schema ?PATTERN? Show the CREATE statements matching PATTERN",
- " Options:",
- " --indent Try to pretty-print the schema",
- " --nosys Omit objects whose names start with \"sqlite_\"",
- ".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 ?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 ... Compute a SHA3 hash of database content",
- " Options:",
- " --schema Also hash the sqlite_schema table",
- " --sha3-224 Use the sha3-224 algorithm",
- " --sha3-256 Use the sha3-256 algorithm (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
- ".show Show the current values for various settings",
- ".stats ?ARG? Show stats or turn stats on or off",
- " off Turn off automatic stat display",
- " on Turn on automatic stat display",
- " stmt Show statement stats",
- " vmstep Show the virtual machine step count only",
-#ifndef SQLITE_NOHAVE_SYSTEM
- ".system CMD ARGS... Run CMD ARGS... in a system shell",
-#endif
- ".tables ?TABLE? List names of tables matching LIKE pattern TABLE",
- ".testcase NAME Begin redirecting output to 'testcase-out.txt'",
- ".testctrl CMD ... Run various sqlite3_test_control() operations",
- " Run \".testctrl\" with no arguments for details",
- ".timeout MS Try opening locked tables for MS milliseconds",
- ".timer on|off Turn SQL timer on or off",
-#ifndef SQLITE_OMIT_TRACE
- ".trace ?OPTIONS? Output each SQL statement as it is run",
- " FILE Send output to FILE",
- " stdout Send output to stdout",
- " stderr Send output to stderr",
- " off Disable tracing",
- " --expanded Expand query parameters",
-#ifdef SQLITE_ENABLE_NORMALIZE
- " --normalized Normal the SQL statements",
-#endif
- " --plain Show SQL as it is input",
- " --stmt Trace statement execution (SQLITE_TRACE_STMT)",
- " --profile Profile statements (SQLITE_TRACE_PROFILE)",
- " --row Trace each row (SQLITE_TRACE_ROW)",
- " --close Trace connection close (SQLITE_TRACE_CLOSE)",
-#endif /* SQLITE_OMIT_TRACE */
-#ifdef SQLITE_DEBUG
- ".unmodule NAME ... Unregister virtual table modules",
- " --allexcept Unregister everything except those named",
-#endif
- ".vfsinfo ?AUX? Information about the top-level VFS",
- ".vfslist List all available VFSes",
- ".vfsname ?AUX? Print the name of the VFS stack",
- ".width NUM1 NUM2 ... Set minimum column widths for columnar output",
- " Negative values right-justify",
-};
-
/*
** Output help text.
**
** Return the number of matches.
*/
static int showHelp(FILE *out, const char *zPattern){
- int i = 0;
- int j = 0;
int n = 0;
char *zPat;
+ const char **pzHxtra;
+ const char **pzH;
if( zPattern==0
|| zPattern[0]=='0'
|| strcmp(zPattern,"-a")==0
){
/* Show all commands, but only one line per command */
if( zPattern==0 ) zPattern = "";
- for(i=0; i<ArraySize(azHelp); i++){
- if( azHelp[i][0]=='.' || zPattern[0] ){
- utf8_printf(out, "%s\n", azHelp[i]);
- n++;
+ for(pzH = azHelp; *pzH != 0; ++pzH){
+ if( *pzH[0]=='.' || zPattern[0] ){
+ utf8_printf(out, "%s\n", *pzH);
+ ++n;
}
}
}else{
/* Look for commands that for which zPattern is an exact prefix */
zPat = sqlite3_mprintf(".%s*", zPattern);
- for(i=0; i<ArraySize(azHelp); i++){
- if( sqlite3_strglob(zPat, azHelp[i])==0 ){
- utf8_printf(out, "%s\n", azHelp[i]);
- j = i+1;
+ for(pzH = azHelp; *pzH != 0; ++pzH){
+ if( sqlite3_strglob(zPat, *pzH)==0 ){
+ utf8_printf(out, "%s\n", *pzH);
+ pzHxtra = pzH + 1;
n++;
}
}
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++;
+ ** details of that command, which should begin at *pzHxtra */
+ while( *pzHxtra !=0 && *pzHxtra[0]!='.' ){
+ utf8_printf(out, "%s\n", *pzHxtra++);
}
}
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;
- if( sqlite3_strlike(zPat, azHelp[i], 0)==0 ){
- utf8_printf(out, "%s\n", azHelp[j]);
- while( j<ArraySize(azHelp)-1 && azHelp[j+1][0]!='.' ){
- j++;
- utf8_printf(out, "%s\n", azHelp[j]);
+ for(pzH = azHelp; *pzH != 0;){
+ if( *pzH[0]=='.' ) pzHxtra = pzH;
+ if( sqlite3_strlike(zPat, *pzHxtra, 0)==0 ){
+ utf8_printf(out, "%s\n", *pzHxtra++);
+ while( *pzHxtra != 0 && *pzHxtra[0]!='.' ){
+ utf8_printf(out, "%s\n", *pzHxtra++);
}
- i = j;
+ pzH = pzHxtra;
n++;
+ } else {
+ ++pzH;
}
}
sqlite3_free(zPat);
}
#endif /* !(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_ENABLE_DBPAGE_VTAB) */
-
+/*****************
+ * The .help command
+ */
+COLLECT_HELP_TEXT[
+ ".help ?-all? ?PATTERN? Show help text for PATTERN",
+];
+COLLECT_DISPATCH( help )[
+ { "help", commandHelp, 3, 1, 0 },
+];
+static int commandHelp(char *azArg[], int nArg, ShellState *p)
+{
+ if( nArg>=2 ){
+ if( showHelp(p->out, azArg[1])==0 ){
+ utf8_printf(p->out, "Nothing matches '%s'\n", azArg[1]);
+ }
+ }else{
+ showHelp(p->out, 0);
+ }
+ /* Help pleas never fail! */
+ return 0;
+}
+
+/* Define and populate command dispatch table. */
+static struct DispatchEntry {
+ const char * cmdName;
+ int (*cmdDoer)(char *azArg[], int nArg, ShellState *);
+ unsigned char minLen, minArgs, maxArgs;
+} command_table[] = {
+ EMIT_DISPATCH();
+ { 0, 0, 0, -1, -1 }
+};
+
+/*****************
+ * Command dispatcher
+ */
+#define NO_SUCH_COMMAND -0x7fff
+#define INVALID_ARGS -0x7ffe
+
+int dispatchCommand(char *azArg[], int nArg, ShellState *pSS)
+{
+ const char *cmdName = azArg[0];
+ /* A temporary, simple-minded scan */
+ struct DispatchEntry *pde = command_table;
+ while (pde->cmdName != 0){
+ if (0==strncmp(cmdName, pde->cmdName, pde->minLen)){
+ if((pde->minArgs > 0 && pde->minArgs > nArg)||(pde->maxArgs > 0 && pde->maxArgs < nArg)){
+ return INVALID_ARGS;
+ }
+ return (pde->cmdDoer)(azArg, nArg, pSS);
+ } else { ++pde; }
+ }
+ return NO_SUCH_COMMAND;
+}
+
+
/*
** If an input line begins with "." then invoke this routine to
** process that line.
}
}else
- if( c=='h' && strncmp(azArg[0], "help", n)==0 ){
- if( nArg>=2 ){
- n = showHelp(p->out, azArg[1]);
- if( n==0 ){
- utf8_printf(p->out, "Nothing matches '%s'\n", azArg[1]);
- }
- }else{
- showHelp(p->out, 0);
- }
- }else
-
if( c=='i' && strncmp(azArg[0], "import", n)==0 ){
char *zTable = 0; /* Insert data into this table */
char *zFile = 0; /* Name of file to extra content from */
p->colWidth[j-1] = (int)integerValue(azArg[j]);
}
}else
-
+ /* The meta-command is not among the specially handled ones. Dispatch it. */
{
- utf8_printf(stderr, "Error: unknown command or invalid arguments: "
- " \"%s\". Enter \".help\" for help\n", azArg[0]);
- rc = 1;
+ int dispatchResult = dispatchCommand(azArg, nArg, p);
+ if( NO_SUCH_COMMAND==dispatchResult || INVALID_ARGS==dispatchResult ){
+ utf8_printf(stderr, "Error: unknown command or invalid arguments: "
+ " \"%s\". Enter \".help\" for help\n", azArg[0]);
+ rc = 1;
+ }
}
meta_command_exit:
sqlite3_free(zBuf);
}
+COLLECT_HELP_TEXT[
+#if defined(SQLITE_HAVE_ZLIB) && !defined(SQLITE_OMIT_VIRTUALTABLE)
+ ".archive ... Manage SQL archives",
+ " Each command must have exactly one of the following options:",
+ " -c, --create Create a new archive",
+ " -u, --update Add or update files with changed mtime",
+ " -i, --insert Like -u but always add even if unchanged",
+ " -t, --list List contents of archive",
+ " -x, --extract Extract files from archive",
+ " Optional arguments:",
+ " -v, --verbose Print each filename as it is processed",
+ " -f FILE, --file FILE Use archive FILE (default is current db)",
+ " -a FILE, --append FILE Open FILE using the apndvfs VFS",
+ " -C DIR, --directory DIR Read/extract files from directory DIR",
+ " -n, --dryrun Show the SQL that would have occurred",
+ " Examples:",
+ " .ar -cf ARCHIVE foo bar # Create ARCHIVE from files foo and bar",
+ " .ar -tf ARCHIVE # List members of ARCHIVE",
+ " .ar -xvf ARCHIVE # Verbosely extract files from ARCHIVE",
+ " See also:",
+ " http://sqlite.org/cli.html#sqlite_archive_support",
+#endif
+];
+COLLECT_HELP_TEXT[
+#ifndef SQLITE_OMIT_AUTHORIZATION
+ ".auth ON|OFF Show authorizer callbacks",
+#endif
+];
+COLLECT_HELP_TEXT[
+ ".backup ?DB? FILE Backup DB (default \"main\") to FILE",
+ " --append Use the appendvfs",
+ " --async Write to FILE without journal and fsync()",
+ ".bail on|off Stop after hitting an error. Default OFF",
+ ".binary on|off Turn binary output on or off. Default OFF",
+ ".cd DIRECTORY Change the working directory to DIRECTORY",
+ ".changes on|off Show number of rows changed by SQL",
+ ".check GLOB Fail if output since .testcase does not match",
+ ".clone NEWDB Clone data into NEWDB from the existing database",
+ ".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 ?OBJECTS? Render database content as SQL",
+ " Options:",
+ " --data-only Output only INSERT statements",
+ " --newlines Allow unescaped newline characters in output",
+ " --nosys Omit system tables (ex: \"sqlite_stat1\")",
+ " --preserve-rowids Include ROWID values in the output",
+ " OBJECTS is a LIKE pattern for tables, indexes, triggers or views to dump",
+ " Additional LIKE patterns can be given in subsequent arguments",
+ ".echo on|off Turn command echo on or off",
+ ".eqp on|off|full|... Enable or disable automatic EXPLAIN QUERY PLAN",
+ " Other Modes:",
+#ifdef SQLITE_DEBUG
+ " test Show raw EXPLAIN QUERY PLAN output",
+ " trace Like \"full\" but enable \"PRAGMA vdbe_trace\"",
+#endif
+ " trigger Like \"full\" but also show trigger bytecode",
+ ".excel Display the output of next command in spreadsheet",
+ " --bom Put a UTF8 byte-order mark on intermediate file",
+ ".exit ?CODE? Exit this program with return-code CODE",
+ ".expert EXPERIMENTAL. Suggest indexes for queries",
+ ".explain ?on|off|auto? Change the EXPLAIN formatting mode. Default: auto",
+ ".filectrl CMD ... Run various sqlite3_file_control() operations",
+ " --schema SCHEMA Use SCHEMA instead of \"main\"",
+ " --help Show CMD details",
+ ".fullschema ?--indent? Show schema and the content of sqlite_stat tables",
+ ".headers on|off Turn display of headers on or off",
+ ".import FILE TABLE Import data from FILE into TABLE",
+ " Options:",
+ " --ascii Use \\037 and \\036 as column and row separators",
+ " --csv Use , and \\n as column and row separators",
+ " --skip N Skip the first N rows of input",
+ " -v \"Verbose\" - increase auxiliary output",
+ " Notes:",
+ " * If TABLE does not exist, it is created. The first row of input",
+ " determines the column names.",
+ " * If neither --csv or --ascii are used, the input mode is derived",
+ " from the \".mode\" output mode",
+ " * If FILE begins with \"|\" then it is a command that generates the",
+ " input text.",
+];
+COLLECT_HELP_TEXT[
+#ifndef SQLITE_OMIT_TEST_CONTROL
+ ".imposter INDEX TABLE Create imposter table TABLE on index INDEX",
+#endif
+];
+COLLECT_HELP_TEXT[
+ ".indexes ?TABLE? Show names of indexes",
+ " If TABLE is specified, only show indexes for",
+ " tables matching TABLE using the LIKE operator.",
+];
+COLLECT_HELP_TEXT[
+#ifdef SQLITE_ENABLE_IOTRACE
+ ".iotrace FILE Enable I/O diagnostic logging to FILE",
+#endif
+];
+COLLECT_HELP_TEXT[
+ ".limit ?LIMIT? ?VAL? Display or change the value of an SQLITE_LIMIT",
+ ".lint OPTIONS Report potential schema issues.",
+ " Options:",
+ " fkey-indexes Find missing foreign key indexes",
+];
+COLLECT_HELP_TEXT[
+#ifndef SQLITE_OMIT_LOAD_EXTENSION
+ ".load FILE ?ENTRY? Load an extension library",
+#endif
+];
+COLLECT_HELP_TEXT[
+ ".log FILE|off Turn logging on or off. FILE can be stderr/stdout",
+ ".mode MODE ?TABLE? Set output mode",
+ " MODE is one of:",
+ " ascii Columns/rows delimited by 0x1F and 0x1E",
+ " box Tables using unicode box-drawing characters",
+ " csv Comma-separated values",
+ " column Output in columns. (See .width)",
+ " html HTML <table> code",
+ " insert SQL insert statements for TABLE",
+ " json Results in a JSON array",
+ " line One value per line",
+ " list Values delimited by \"|\"",
+ " markdown Markdown table format",
+ " quote Escape answers as for SQL",
+ " table ASCII-art table",
+ " tabs Tab-separated values",
+ " tcl TCL list elements",
+ ".nullvalue STRING Use STRING in place of NULL values",
+ ".once ?OPTIONS? ?FILE? Output for the next SQL command only to FILE",
+ " If FILE begins with '|' then open as a pipe",
+ " --bom Put a UTF8 byte-order mark at the beginning",
+ " -e Send output to the system text editor",
+ " -x Send output as CSV to a spreadsheet (same as \".excel\")",
+];
+COLLECT_HELP_TEXT[
+#ifdef SQLITE_DEBUG
+ ".oom ?--repeat M? ?N? Simulate an OOM error on the N-th allocation",
+#endif
+];
+COLLECT_HELP_TEXT[
+ ".open ?OPTIONS? ?FILE? Close existing database and reopen FILE",
+ " Options:",
+ " --append Use appendvfs to append database to the end of FILE",
+#ifndef SQLITE_OMIT_DESERIALIZE
+ " --deserialize Load into memory using sqlite3_deserialize()",
+ " --hexdb Load the output of \"dbtotxt\" as an in-memory db",
+ " --maxsize N Maximum size for --hexdb or --deserialized database",
+#endif
+ " --new Initialize FILE to an empty database",
+ " --nofollow Do not follow symbolic links",
+ " --readonly Open FILE readonly",
+ " --zip FILE is a ZIP archive",
+ ".output ?FILE? Send output to FILE or stdout if FILE is omitted",
+ " If FILE begins with '|' then open it as a pipe.",
+ " Options:",
+ " --bom Prefix output with a UTF8 byte-order mark",
+ " -e Send output to the system text editor",
+ " -x Send output as CSV to a spreadsheet",
+ ".parameter CMD ... Manage SQL parameter bindings",
+ " clear Erase all bindings",
+ " init Initialize the TEMP table that holds bindings",
+ " list List the current parameter bindings",
+ " set PARAMETER VALUE Given SQL parameter PARAMETER a value of VALUE",
+ " PARAMETER should start with one of: $ : @ ?",
+ " unset PARAMETER Remove PARAMETER from the binding table",
+ ".print STRING... Print literal STRING",
+];
+COLLECT_HELP_TEXT[
+#ifndef SQLITE_OMIT_PROGRESS_CALLBACK
+ ".progress N Invoke progress handler after every N opcodes",
+ " --limit N Interrupt after N progress callbacks",
+ " --once Do no more than one progress interrupt",
+ " --quiet|-q No output except at interrupts",
+ " --reset Reset the count for each input and interrupt",
+#endif
+];
+COLLECT_HELP_TEXT[
+ ".prompt MAIN CONTINUE Replace the standard prompts",
+ ".quit Exit this program",
+ ".read FILE Read input from FILE",
+];
+COLLECT_HELP_TEXT[
+#if !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_ENABLE_DBPAGE_VTAB)
+ ".recover Recover as much data as possible from corrupt db.",
+ " --freelist-corrupt Assume the freelist is corrupt",
+ " --recovery-db NAME Store recovery metadata in database file NAME",
+ " --lost-and-found TABLE Alternative name for the lost-and-found table",
+ " --no-rowids Do not attempt to recover rowid values",
+ " that are not also INTEGER PRIMARY KEYs",
+#endif
+];
+COLLECT_HELP_TEXT[
+ ".restore ?DB? FILE Restore content of DB (default \"main\") from FILE",
+ ".save FILE Write in-memory database into FILE",
+ ".scanstats on|off Turn sqlite3_stmt_scanstatus() metrics on or off",
+ ".schema ?PATTERN? Show the CREATE statements matching PATTERN",
+ " Options:",
+ " --indent Try to pretty-print the schema",
+ " --nosys Omit objects whose names start with \"sqlite_\"",
+ ".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",
+];
+COLLECT_HELP_TEXT[
+#if defined(SQLITE_ENABLE_SESSION)
+ ".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
+];
+COLLECT_HELP_TEXT[
+ ".sha3sum ... Compute a SHA3 hash of database content",
+ " Options:",
+ " --schema Also hash the sqlite_schema table",
+ " --sha3-224 Use the sha3-224 algorithm",
+ " --sha3-256 Use the sha3-256 algorithm (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",
+];
+COLLECT_HELP_TEXT[
+#ifndef SQLITE_NOHAVE_SYSTEM
+ ".shell CMD ARGS... Run CMD ARGS... in a system shell",
+#endif
+];
+COLLECT_HELP_TEXT[
+ ".show Show the current values for various settings",
+ ".stats ?ARG? Show stats or turn stats on or off",
+ " off Turn off automatic stat display",
+ " on Turn on automatic stat display",
+ " stmt Show statement stats",
+ " vmstep Show the virtual machine step count only",
+];
+COLLECT_HELP_TEXT[
+#ifndef SQLITE_NOHAVE_SYSTEM
+ ".system CMD ARGS... Run CMD ARGS... in a system shell",
+#endif
+];
+COLLECT_HELP_TEXT[
+ ".tables ?TABLE? List names of tables matching LIKE pattern TABLE",
+ ".testcase NAME Begin redirecting output to 'testcase-out.txt'",
+ ".testctrl CMD ... Run various sqlite3_test_control() operations",
+ " Run \".testctrl\" with no arguments for details",
+ ".timeout MS Try opening locked tables for MS milliseconds",
+ ".timer on|off Turn SQL timer on or off",
+];
+COLLECT_HELP_TEXT[
+#ifndef SQLITE_OMIT_TRACE
+ ".trace ?OPTIONS? Output each SQL statement as it is run",
+ " FILE Send output to FILE",
+ " stdout Send output to stdout",
+ " stderr Send output to stderr",
+ " off Disable tracing",
+ " --expanded Expand query parameters",
+#ifdef SQLITE_ENABLE_NORMALIZE
+ " --normalized Normal the SQL statements",
+#endif
+ " --plain Show SQL as it is input",
+ " --stmt Trace statement execution (SQLITE_TRACE_STMT)",
+ " --profile Profile statements (SQLITE_TRACE_PROFILE)",
+ " --row Trace each row (SQLITE_TRACE_ROW)",
+ " --close Trace connection close (SQLITE_TRACE_CLOSE)",
+#endif /* SQLITE_OMIT_TRACE */
+];
+COLLECT_HELP_TEXT[
+#ifdef SQLITE_DEBUG
+ ".unmodule NAME ... Unregister virtual table modules",
+ " --allexcept Unregister everything except those named",
+#endif
+];
+COLLECT_HELP_TEXT[
+ ".vfsinfo ?AUX? Information about the top-level VFS",
+ ".vfslist List all available VFSes",
+ ".vfsname ?AUX? Print the name of the VFS stack",
+ ".width NUM1 NUM2 ... Set minimum column widths for columnar output",
+ " Negative values right-justify",
+];
+
+/*
+** Text of help messages.
+**
+** The help text for each individual command begins with a line that starts
+** with ".". Subsequent lines are supplimental information.
+**
+** There must be two or more spaces between the end of the command and the
+** start of the description of what that command does.
+*/
+static const char *(azHelp[]) = {
+ EMIT_HELP_TEXT();
+ 0
+};
+
/*
** Show available command line options
*/