From 13062a14791650066d542745f092abec4fe11741 Mon Sep 17 00:00:00 2001 From: wyhaya Date: Sat, 8 Feb 2025 15:11:09 +0800 Subject: [PATCH] cli: Add column names in Pretty mode --- cli/app.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/cli/app.rs b/cli/app.rs index 7d812d7fe..729a8cf6e 100644 --- a/cli/app.rs +++ b/cli/app.rs @@ -2,7 +2,7 @@ use crate::{ import::{ImportFile, IMPORT_HELP}, opcodes_dictionary::OPCODE_DESCRIPTIONS, }; -use cli_table::{Cell, Table}; +use cli_table::{Cell, Style, Table}; use limbo_core::{Database, LimboError, Statement, StepResult, Value}; use clap::{Parser, ValueEnum}; @@ -670,6 +670,16 @@ impl Limbo { return Ok(()); } let mut table_rows: Vec> = vec![]; + if rows.num_columns() > 0 { + let columns = (0..rows.num_columns()) + .map(|i| { + rows.get_column_name(i) + .map(|name| name.cell().bold(true)) + .unwrap_or_else(|| " ".cell()) + }) + .collect::>(); + table_rows.push(columns); + } loop { match rows.step() { Ok(StepResult::Row) => {