MCPcopy Create free account
hub / github.com/duckdb/duckdb / SetOutputMode

Method SetOutputMode

tools/shell/shell.cpp:1588–1657  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1586}
1587
1588bool ShellState::SetOutputMode(const string &mode_name, const char *tbl_name) {
1589 auto mode_str = mode_name.c_str();
1590 idx_t n2 = mode_name.size();
1591 char c2 = mode_str[0];
1592 if (tbl_name && !(c2 == 'i' && strncmp(mode_str, "insert", n2) == 0)) {
1593 PrintF(PrintOutput::STDERR, "TABLE argument can only be used with .mode insert");
1594 return false;
1595 }
1596 if (c2 == 'l' && n2 > 2 && strncmp(mode_str, "lines", n2) == 0) {
1597 mode = RenderMode::LINE;
1598 rowSeparator = SEP_Row;
1599 } else if (c2 == 'c' && strncmp(mode_str, "columns", n2) == 0) {
1600 mode = RenderMode::COLUMN;
1601 if (ShellHasFlag(ShellFlags::SHFLG_HeaderSet)) {
1602 showHeader = true;
1603 }
1604 rowSeparator = SEP_Row;
1605 } else if (c2 == 'l' && n2 > 2 && strncmp(mode_str, "list", n2) == 0) {
1606 mode = RenderMode::LIST;
1607 colSeparator = SEP_Column;
1608 rowSeparator = SEP_Row;
1609 } else if (c2 == 'h' && strncmp(mode_str, "html", n2) == 0) {
1610 mode = RenderMode::HTML;
1611 } else if (c2 == 't' && strncmp(mode_str, "tcl", n2) == 0) {
1612 mode = RenderMode::TCL;
1613 colSeparator = SEP_Space;
1614 rowSeparator = SEP_Row;
1615 } else if (c2 == 'c' && strncmp(mode_str, "csv", n2) == 0) {
1616 mode = RenderMode::CSV;
1617 colSeparator = SEP_Comma;
1618 rowSeparator = SEP_CrLf;
1619 } else if (c2 == 't' && strncmp(mode_str, "tabs", n2) == 0) {
1620 mode = RenderMode::LIST;
1621 colSeparator = SEP_Tab;
1622 } else if (c2 == 'i' && strncmp(mode_str, "insert", n2) == 0) {
1623 mode = RenderMode::INSERT;
1624 SetTableName(tbl_name ? tbl_name : "table");
1625 } else if (c2 == 'q' && strncmp(mode_str, "quote", n2) == 0) {
1626 mode = RenderMode::QUOTE;
1627 colSeparator = SEP_Comma;
1628 rowSeparator = SEP_Row;
1629 } else if (c2 == 'a' && strncmp(mode_str, "ascii", n2) == 0) {
1630 mode = RenderMode::ASCII;
1631 colSeparator = SEP_Unit;
1632 rowSeparator = SEP_Record;
1633 } else if (c2 == 'm' && strncmp(mode_str, "markdown", n2) == 0) {
1634 mode = RenderMode::MARKDOWN;
1635 } else if (c2 == 't' && strncmp(mode_str, "table", n2) == 0) {
1636 mode = RenderMode::TABLE;
1637 } else if (c2 == 'b' && strncmp(mode_str, "box", n2) == 0) {
1638 mode = RenderMode::BOX;
1639 } else if (c2 == 'd' && strncmp(mode_str, "duckbox", n2) == 0) {
1640 mode = RenderMode::DUCKBOX;
1641 } else if (c2 == 'j' && strncmp(mode_str, "json", n2) == 0) {
1642 mode = RenderMode::JSON;
1643 } else if (c2 == 'l' && strncmp(mode_str, "latex", n2) == 0) {
1644 mode = RenderMode::LATEX;
1645 } else if (c2 == 't' && strncmp(mode_str, "trash", n2) == 0) {

Callers 1

SetOutputModeFunction · 0.80

Calls 2

c_strMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected