From: drh <> Date: Sat, 22 Nov 2025 23:34:53 +0000 (+0000) Subject: Add "split" mode in the CLI. Fix CLI commands given on the command line X-Git-Tag: artiphishell~199 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c4190338c53bfdc0b45b671843b368ec198f273a;p=thirdparty%2Fsqlite.git Add "split" mode in the CLI. Fix CLI commands given on the command line so that they honor --once in prior commands. FossilOrigin-Name: 2530f04d1bb02b800fda83544f5b5dcd42f52b3e56ad625cd03b40e42f24ac6b --- diff --git a/manifest b/manifest index 5d4bc27f48..a7d4622136 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\s--no-limits\soption\sto\sthe\s.mode\scommand\sin\sthe\sCLI. -D 2025-11-22T21:47:48.856 +C Add\s"split"\smode\sin\sthe\sCLI.\s\sFix\sCLI\scommands\sgiven\son\sthe\scommand\sline\nso\sthat\sthey\shonor\s--once\sin\sprior\scommands. +D 2025-11-22T23:34:53.769 F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea @@ -735,7 +735,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c F src/resolve.c 5616fbcf3b833c7c705b24371828215ad0925d0c0073216c4f153348d5753f0a F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c ba9cd07ffa3277883c1986085f6ddc4320f4d35d5f212ab58df79a7ecc1a576a -F src/shell.c.in bbd55e63e9ae9f33e96a9511dc21a4be3f9be3b1fb7a492bdd1c725258a69682 +F src/shell.c.in 977f8b9b108f37cdcce4c1a0f17e7809666aaa6c504f0752eb8c4ec7122999c4 F src/sqlite.h.in f1363321ca55cc2feaa289e9fe6dfb08102a28c54edf005564711a2348b06eef F src/sqlite3.rc 015537e6ac1eec6c7050e17b616c2ffe6f70fca241835a84a4f0d5937383c479 F src/sqlite3ext.h 5d5330f5f8461f5ce74960436ddcfa53ecd09c2b8b23901e22ae38aec3243998 @@ -1614,7 +1614,7 @@ F test/shell6.test e3b883b61d4916b6906678a35f9d19054861123ad91b856461e0a456273bd F test/shell7.test 43fd8e511c533bab5232e95c7b4be93b243451709e89582600d4b6e67693d5c3 F test/shell8.test 641cf21a99c59404c24e3062923734951c4099a6b6b6520de00cf7a1249ee871 F test/shell9.test 8742a5b390cdcef6369f5aa223e415aa4255a4129ef249b177887dc635a87209 -F test/shellA.test 4ece22f204532fb04ab702c5b9c70d8680ff610bff1e82c849c16a7b5cd57d83 +F test/shellA.test 4b8983a40703b5550f691592b6c5bc64886c26755eeb7a474af849d1e39b51f2 F test/shellB.test de879b1ea7c25daf1a06b2c882b45a5d002e6580c81c57169ce47084cc6afb6b F test/shmlock.test 9f1f729a7fe2c46c88b156af819ac9b72c0714ac6f7246638a73c5752b5fd13c F test/shortread1.test bb591ef20f0fd9ed26d0d12e80eee6d7ac8897a3 @@ -2178,8 +2178,8 @@ F tool/version-info.c 33d0390ef484b3b1cb685d59362be891ea162123cea181cb8e6d2cf6dd F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh d924598cf2f55a4ecbc2aeb055c10bd5f48114793e7ba25f9585435da29e7e98 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 76512b3b80fdcaae22340cde0b69857e2a4d7e86a63c6759465bd8a0bcbf82bc -R fd59072a32f0d4099969082466a9a77e +P 3cee168e8801481f6d909fb5d20a773b9c6ca0b8daedfc301c9d762a17f9d839 +R 53605c07fff250aecf8e1982cc6fddce U drh -Z 8f5059e4a9fa8586168b58aff36d75e6 +Z 5d5dcf7a665f0cd59987ab755e809ab9 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 0a8421cd6c..10635e60bb 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3cee168e8801481f6d909fb5d20a773b9c6ca0b8daedfc301c9d762a17f9d839 +2530f04d1bb02b800fda83544f5b5dcd42f52b3e56ad625cd03b40e42f24ac6b diff --git a/src/shell.c.in b/src/shell.c.in index 7d4bb269cd..aab18624a5 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -1430,12 +1430,13 @@ static const char *qrfQuoteNames[] = #define MODE_Off 14 /* No query output shown */ #define MODE_QBox 15 /* BOX with SQL-quoted content */ #define MODE_Quote 16 /* Quote values as for SQL */ -#define MODE_Table 17 /* MySQL-style table formatting */ -#define MODE_Tabs 18 /* Tab-separated values */ -#define MODE_Tcl 19 /* Space-separated list of TCL strings */ -#define MODE_Www 20 /* Full web-page output */ +#define MODE_Split 17 /* Split-column mode */ +#define MODE_Table 18 /* MySQL-style table formatting */ +#define MODE_Tabs 19 /* Tab-separated values */ +#define MODE_Tcl 20 /* Space-separated list of TCL strings */ +#define MODE_Www 21 /* Full web-page output */ -#define MODE_BUILTIN 20 /* Maximum built-in mode */ +#define MODE_BUILTIN 21 /* Maximum built-in mode */ #define MODE_BATCH 50 /* Default mode for batch processing */ #define MODE_TTY 51 /* Default mode for interactive processing */ #define MODE_USER 75 /* First user-defined mode */ @@ -1484,6 +1485,7 @@ static const ModeInfo aModeInfo[] = { { "off", 0, 0, 0, 0, 0, 0, 0, 14, 0 }, { "qbox", 0, 0, 9, 2, 1, 2, 2, 1, 2 }, { "quote", 4, 1, 10, 2, 2, 2, 1, 12, 0 }, + { "split", 0, 0, 9, 1, 1, 1, 1, 2, 2 }, { "table", 0, 0, 9, 1, 1, 1, 2, 19, 2 }, { "tabs", 8, 1, 9, 3, 3, 1, 1, 12, 0 }, { "tcl", 3, 1, 12, 5, 5, 4, 1, 12, 0 }, @@ -1612,6 +1614,12 @@ static void modeChange(ShellState *p, unsigned char eMode){ pM->spec.eBlob = pI->eBlob; pM->spec.bTitles = pI->bHdr; pM->spec.eTitle = pI->eHdr; + if( eMode==MODE_Split ){ + pM->spec.bSplitColumn = QRF_Yes; + pM->bAutoScreenWidth = 1; + }else{ + pM->spec.bSplitColumn = QRF_No; + } }else if( eMode>=MODE_USER && eMode-MODE_USERnSavedModes ){ modeFree(&p->mode); modeDup(&p->mode, &p->aSavedModes[eMode-MODE_USER].mode); @@ -13005,6 +13013,16 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){ if( rc==0 ) rc = 1; goto shell_main_exit; } + if( data.nPopMode ){ + modePop(&data); + data.nPopMode = 0; + } + } + if( data.nPopOutput ){ + output_reset(&data); + data.nPopOutput = 0; + }else{ + clearTempFile(&data); } } }else{ diff --git a/test/shellA.test b/test/shellA.test index c2694479b9..e3d2e1b9d0 100644 --- a/test/shellA.test +++ b/test/shellA.test @@ -250,4 +250,83 @@ INSERT INTO t1 VALUES(7,'carriage\rreturn'); INSERT INTO t1 VALUES(8,'last line'); " +# ".mode split" +# +do_test shellA-6.1 { + db eval { + CREATE TABLE t2(x); + INSERT INTO t2(x) VALUES + ('one'), ('two'), ('three'), ('four'), ('five'), + ('six'), ('seven'), ('eight'), ('nine'), ('ten'), + ('eleven'), ('twelve'), ('thirteen'), ('fourteen'); + } + exec {*}$CLI -noinit test.db \ + {.print} \ + {.mode split -screenwidth 30} \ + {SELECT x FROM t2} +} { +one five nine thirteen +two six ten fourteen +three seven eleven +four eight twelve} +# 3456789 123456789 123456789 + +do_test shellA-6.2 { + exec {*}$CLI -noinit test.db \ + {.print} \ + {.mode split -screenwidth 30} \ + {SELECT x FROM t2} \ + {.mode column -titles off} \ + {SELECT x FROM t2} +} { +one five nine thirteen +two six ten fourteen +three seven eleven +four eight twelve +one +two +three +four +five +six +seven +eight +nine +ten +eleven +twelve +thirteen +fourteen} + +do_test shellA-6.3 { + exec {*}$CLI -noinit test.db \ + {.print} \ + {.mode table} \ + {.mode --once split -screenwidth 30} \ + {SELECT x FROM t2} \ + {SELECT x FROM t2} +} { +one five nine thirteen +two six ten fourteen +three seven eleven +four eight twelve ++----------+ +| x | ++----------+ +| one | +| two | +| three | +| four | +| five | +| six | +| seven | +| eight | +| nine | +| ten | +| eleven | +| twelve | +| thirteen | +| fourteen | ++----------+} + finish_test