/ Check-in [fe284afe]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add the ".save" command as an alias for ".backup". Improvements to the way font changes are implemented on the in-memory database warning.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | memdb-warning
Files: files | file ages | folders
SHA1: fe284afe739c497e153ac2bc0275f7c9e862c824
User & Date: drh 2014-02-10 19:59:27
Context
2014-02-11
16:22
Updates to the command-line shell. Simplify the banner message. Add the ".save" command as an alias for ".backup". When starting with no arguments, include a banner message warning that the database is transient and in-memory and mention the ".open" command. check-in: f5ad1e1b user: drh tags: trunk
2014-02-10
19:59
Add the ".save" command as an alias for ".backup". Improvements to the way font changes are implemented on the in-memory database warning. Closed-Leaf check-in: fe284afe user: drh tags: memdb-warning
19:36
On unix, make the "transient in-memory database" text bold, but not red. Leave the text read on windows. check-in: c9eba2f7 user: drh tags: memdb-warning
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/shell.c.

  1579   1579     ".output FILENAME       Send output to FILENAME\n"
  1580   1580     ".output stdout         Send output to the screen\n"
  1581   1581     ".print STRING...       Print literal STRING\n"
  1582   1582     ".prompt MAIN CONTINUE  Replace the standard prompts\n"
  1583   1583     ".quit                  Exit this program\n"
  1584   1584     ".read FILENAME         Execute SQL in FILENAME\n"
  1585   1585     ".restore ?DB? FILE     Restore content of DB (default \"main\") from FILE\n"
         1586  +  ".save FILE             Write in-memory database into FILE\n"
  1586   1587     ".schema ?TABLE?        Show the CREATE statements\n"
  1587   1588     "                         If TABLE specified, only show tables matching\n"
  1588   1589     "                         LIKE pattern TABLE.\n"
  1589   1590     ".separator STRING      Change separator used by output mode and .import\n"
  1590   1591     ".show                  Show the current values for various settings\n"
  1591   1592     ".stats ON|OFF          Turn stats on or off\n"
  1592   1593     ".tables ?TABLE?        List names of tables\n"
................................................................................
  2148   2149     }
  2149   2150   
  2150   2151     /* Process the input line.
  2151   2152     */
  2152   2153     if( nArg==0 ) return 0; /* no tokens, no error */
  2153   2154     n = strlen30(azArg[0]);
  2154   2155     c = azArg[0][0];
  2155         -  if( c=='b' && n>=3 && strncmp(azArg[0], "backup", n)==0 ){
         2156  +  if( (c=='b' && n>=3 && strncmp(azArg[0], "backup", n)==0)
         2157  +   || (c=='s' && n>=3 && strncmp(azArg[0], "save", n)==0)
         2158  +  ){
  2156   2159       const char *zDestFile = 0;
  2157   2160       const char *zDb = 0;
  2158   2161       sqlite3 *pDest;
  2159   2162       sqlite3_backup *pBackup;
  2160   2163       int j;
  2161   2164       for(j=1; j<nArg; j++){
  2162   2165         const char *z = azArg[j];
................................................................................
  3497   3500     sqlite3_config(SQLITE_CONFIG_LOG, shellLog, data);
  3498   3501     sqlite3_snprintf(sizeof(mainPrompt), mainPrompt,"sqlite> ");
  3499   3502     sqlite3_snprintf(sizeof(continuePrompt), continuePrompt,"   ...> ");
  3500   3503     sqlite3_config(SQLITE_CONFIG_SINGLETHREAD);
  3501   3504   }
  3502   3505   
  3503   3506   /*
  3504         -** Arrange for subsequent text console output to be RED or normal.  Use
  3505         -** the SetConsoleTextAttribute() function on windows.  On all other
  3506         -** platforms, assume VT100 escape sequences are recognized.
         3507  +** Output text to the console in a font that attracts extra attention.
  3507   3508   */
  3508   3509   #ifdef _WIN32
  3509         -static void outputRed(void){
  3510         -   SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
  3511         -         FOREGROUND_RED|FOREGROUND_INTENSITY);
  3512         -}
  3513         -static void outputNormal(void){
  3514         -  SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
  3515         -         FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
         3510  +static void printBold(const char *zText){
         3511  +  HANDLE out = GetStdHandle(STD_OUTPUT_HANDLE);
         3512  +  CONSOLE_SCREEN_BUFFER_INFO defaultScreenInfo;
         3513  +  GetConsoleScreenBufferInfo(out, &defaultScreenInfo);
         3514  +  SetConsoleTextAttribute(out,
         3515  +         FOREGROUND_RED|FOREGROUND_INTENSITY
         3516  +  );
         3517  +  printf("%s", zText);
         3518  +  SetConsoleTextAttribute(out, defaultScreenInfo.wAttributes);
  3516   3519   }
  3517   3520   #else
  3518         -static void outputRed(void){
  3519         -  printf("\033[1m");
  3520         -}
  3521         -static void outputNormal(void){
  3522         -  printf("\033[0m");
         3521  +static void printBold(const char *zText){
         3522  +  printf("\033[1m%s\033[0m", zText);
  3523   3523   }
  3524   3524   #endif
  3525   3525   
  3526   3526   /*
  3527   3527   ** Get the argument to an --option.  Throw an error and die if no argument
  3528   3528   ** is available.
  3529   3529   */
................................................................................
  3776   3776         printf(
  3777   3777           "SQLite version %s %.19s\n" /*extra-version-info*/
  3778   3778           "Enter \".help\" for usage hints.\n",
  3779   3779           sqlite3_libversion(), sqlite3_sourceid()
  3780   3780         );
  3781   3781         if( warnInmemoryDb ){
  3782   3782           printf("Connected to a ");
  3783         -        outputRed();
  3784         -        printf("transient in-memory database");
  3785         -        outputNormal();
  3786         -        printf(".\nUse \".open FILENAME\" to reopen on a "
         3783  +        printBold("transient in-memory database.");
         3784  +        printf("\nUse \".open FILENAME\" to reopen on a "
  3787   3785                  "persistent database.\n");
  3788   3786         }
  3789   3787         zHome = find_home_dir();
  3790   3788         if( zHome ){
  3791   3789           nHistory = strlen30(zHome) + 20;
  3792   3790           if( (zHistory = malloc(nHistory))!=0 ){
  3793   3791             sqlite3_snprintf(nHistory, zHistory,"%s/.sqlite_history", zHome);