unsigned char eTitle; /* Header incoding. */
unsigned char eStyle; /* Underlying QRF style */
unsigned char eCx; /* 0: other, 1: line, 2: columnar */
+ unsigned char bTx; /* Column headers enabled by default */
};
static const char *aModeStr[] =
/* 0 1 2 3 4 5 6 7 8 9 10 11 */
{ 0, "\n", "|", " ", ",", "\r\n", "\036", "\037", "\t", "", "NULL", "null" };
static const ModeInfo aModeInfo[] = {
-/* zName eCSep eRSep eNull eText eBlob bHdr eTitle eStyle eCx */
- { "ascii", 7, 6, 9, 1, 1, 1, 1, 12, 0 },
- { "box", 0, 0, 9, 1, 1, 2, 1, 1, 2 },
- { "c", 4, 1, 2, 5, 4, 1, 5, 12, 0 },
- { "column", 0, 0, 9, 1, 1, 2, 1, 2, 2 },
- { "count", 0, 0, 0, 0, 0, 0, 0, 3, 0 },
- { "csv", 4, 5, 9, 3, 1, 1, 3, 12, 0 },
- { "html", 0, 0, 9, 4, 1, 2, 4, 7, 0 },
- { "insert", 0, 0, 10, 2, 2, 1, 2, 8, 0 },
- { "jatom", 4, 1, 11, 6, 5, 1, 6, 12, 0 },
- { "jobject", 0, 1, 11, 6, 5, 0, 0, 10, 0 },
- { "json", 0, 0, 11, 6, 6, 0, 0, 9, 0 },
- { "line", 0, 1, 9, 1, 1, 0, 0, 11, 1 },
- { "list", 2, 1, 9, 1, 1, 1, 1, 12, 0 },
- { "markdown", 0, 0, 9, 1, 1, 2, 1, 13, 2 },
- { "off", 0, 0, 0, 0, 0, 0, 0, 14, 0 },
- { "qbox", 0, 0, 9, 2, 2, 2, 1, 1, 2 },
- { "quote", 4, 1, 10, 2, 2, 1, 2, 12, 0 },
- { "table", 0, 0, 9, 1, 1, 2, 1, 19, 2 },
- { "tabs", 8, 1, 9, 3, 1, 1, 3, 12, 0 },
- { "tcl", 3, 1, 9, 5, 4, 1, 5, 12, 0 },
- { "www", 0, 0, 9, 4, 1, 2, 4, 7, 0 },
+/* zName eCSep eRSep eNull eText eBlob bHdr eTitle eStyle eCx bTx */
+ { "ascii", 7, 6, 9, 1, 1, 1, 1, 12, 0, 0 },
+ { "box", 0, 0, 9, 1, 1, 2, 1, 1, 2, 1 },
+ { "c", 4, 1, 2, 5, 4, 1, 5, 12, 0, 0 },
+ { "column", 0, 0, 9, 1, 1, 2, 1, 2, 2, 1 },
+ { "count", 0, 0, 0, 0, 0, 0, 0, 3, 0, 0 },
+ { "csv", 4, 5, 9, 3, 1, 1, 3, 12, 0, 0 },
+ { "html", 0, 0, 9, 4, 1, 2, 4, 7, 0, 0 },
+ { "insert", 0, 0, 10, 2, 2, 1, 2, 8, 0, 0 },
+ { "jatom", 4, 1, 11, 6, 5, 1, 6, 12, 0, 0 },
+ { "jobject", 0, 1, 11, 6, 5, 0, 0, 10, 0, 0 },
+ { "json", 0, 0, 11, 6, 6, 0, 0, 9, 0, 0 },
+ { "line", 0, 1, 9, 1, 1, 0, 0, 11, 1, 0 },
+ { "list", 2, 1, 9, 1, 1, 1, 1, 12, 0, 0 },
+ { "markdown", 0, 0, 9, 1, 1, 2, 1, 13, 2, 1 },
+ { "off", 0, 0, 0, 0, 0, 0, 0, 14, 0, 0 },
+ { "qbox", 0, 0, 9, 2, 2, 2, 1, 1, 2, 1 },
+ { "quote", 4, 1, 10, 2, 2, 1, 2, 12, 0, 0 },
+ { "table", 0, 0, 9, 1, 1, 2, 1, 19, 2, 1 },
+ { "tabs", 8, 1, 9, 3, 1, 1, 3, 12, 0, 0 },
+ { "tcl", 3, 1, 9, 5, 4, 1, 5, 12, 0, 0 },
+ { "www", 0, 0, 9, 4, 1, 2, 4, 7, 0, 1 },
}; /* | / / \ \ | / /
** | / / \ \ | / /
** First three columns These five column use integers that
**
** --textjsonb BOOLEAN If enabled, JSONB text is displayed as text JSON.
**
+** --title ARG Whether or not to show column headers, and if so
+** how to encode them. ARG can be "off", "on",
+** "sql", "csv", "html", "tcl", or "json".
+**
** -v|--verbose Verbose output
**
** --widths LIST Set the columns widths for columnar modes. The
}
p->mode.spec.bTextJsonb = booleanValue(azArg[++i]) ? QRF_Yes : QRF_No;
chng = 1;
+ }else if( optionMatch(z,"titles") ){
+ char *zErr = 0;
+ if( i+1>=nArg ){
+ dotCmdError(p, i, "missing argument", 0);
+ return 1;
+ }
+ k = pickStr(azArg[++i],&zErr,
+ "off","on","plain","sql","html","tcl","json","");
+ /* 0 1 2 3 4 5 6 */
+ if( k<0 ){
+ dotCmdError(p, i, "bad --titles value","%z", zErr);
+ return 1;
+ }
+ p->mode.spec.bTitles = k>=1 ? QRF_Yes : QRF_No;
+ p->mode.spec.eTitle = k>1 ? k-1 : aModeInfo[p->mode.eMode].eTitle;
+ chng = 1;
}else if( optionMatch(z,"widths") ){
int nWidth = 0;
short int *aWidth;
sqlite3_str *pDesc = sqlite3_str_new(p->db);
char *zDesc;
const char *zSetting;
+ int bSameTitle;
+ int bTitleOn;
sqlite3_str_appendall(pDesc,pI->zName);
if( bAll || (p->mode.spec.nAlign && pI->eCx==2) ){
int i;
sqlite3_str_appendf(pDesc," --textjsonb %s",
p->mode.spec.bTextJsonb==QRF_Yes ? "on" : "off");
}
+ bSameTitle = p->mode.spec.eTitle==pI->eTitle;
+ bTitleOn = (p->mode.spec.bTitles==QRF_Yes);
+ if( bAll || bTitleOn!=pI->bTx || (bTitleOn && !bSameTitle) ){
+ static const char *azTitle[] =
+ { "off", "on", "plain", "sql", "csv", "html", "tcl", "json"};
+ if( !bTitleOn ){
+ k = 0;
+ }else if( bSameTitle ){
+ k = 1;
+ }else{
+ k = p->mode.spec.eTitle+1;
+ }
+ sqlite3_str_appendf(pDesc," --titles %s", azTitle[k]);
+ }
if( p->mode.spec.nWidth>0 && (bAll || pI->eCx==2) ){
int i;
const char *zSep = " --widths ";
if( c=='h' && cli_strncmp(azArg[0], "headers", n)==0 ){
if( nArg==2 ){
p->mode.spec.bTitles = booleanValue(azArg[1]) ? QRF_Yes : QRF_No;
+ p->mode.spec.eTitle = aModeInfo[p->mode.eMode].eTitle;
}else{
eputz("Usage: .headers on|off\n");
rc = 1;