mirror of
https://github.com/aljazceru/turso.git
synced 2026-02-19 15:05:47 +01:00
adding table colors
This commit is contained in:
@@ -20,23 +20,24 @@ path = "main.rs"
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1.0.75"
|
||||
cfg-if = "1.0.0"
|
||||
clap = { version = "4.5", features = ["derive"] }
|
||||
comfy-table = "7.1.4"
|
||||
csv = "1.3.1"
|
||||
ctrlc = "3.4.4"
|
||||
dirs = "5.0.1"
|
||||
env_logger = "0.10.1"
|
||||
limbo_core = { path = "../core", default-features = true, features = [
|
||||
"completion",
|
||||
] }
|
||||
miette = { version = "7.4.0", features = ["fancy"] }
|
||||
rustyline = { version = "15.0.0", default-features = true, features = [
|
||||
"derive",
|
||||
] }
|
||||
syntect = "5.2.0"
|
||||
tracing = "0.1.41"
|
||||
ctrlc = "3.4.4"
|
||||
csv = "1.3.1"
|
||||
miette = { version = "7.4.0", features = ["fancy"] }
|
||||
cfg-if = "1.0.0"
|
||||
tracing-subscriber = { version = "0.3.19", features = ["env-filter"] }
|
||||
tracing = "0.1.41"
|
||||
syntect = "5.2.0"
|
||||
|
||||
|
||||
[features]
|
||||
default = ["io_uring"]
|
||||
|
||||
25
cli/app.rs
25
cli/app.rs
@@ -4,7 +4,7 @@ use crate::{
|
||||
input::{get_io, get_writer, DbLocation, Io, OutputMode, Settings, HELP_MSG},
|
||||
opcodes_dictionary::OPCODE_DESCRIPTIONS,
|
||||
};
|
||||
use comfy_table::{Attribute, Cell, CellAlignment, ContentArrangement, Row, Table};
|
||||
use comfy_table::{Attribute, Cell, CellAlignment, Color, ContentArrangement, Row, Table};
|
||||
use limbo_core::{Database, LimboError, OwnedValue, Statement, StepResult};
|
||||
|
||||
use clap::{Parser, ValueEnum};
|
||||
@@ -742,24 +742,31 @@ impl<'a> Limbo<'a> {
|
||||
let mut row = Row::new();
|
||||
row.max_height(1);
|
||||
for value in record.get_values() {
|
||||
let (content, alignment) = match value {
|
||||
OwnedValue::Null => {
|
||||
(self.opts.null_value.clone(), CellAlignment::Left)
|
||||
}
|
||||
let (content, alignment, color) = match value {
|
||||
OwnedValue::Null => (
|
||||
self.opts.null_value.clone(),
|
||||
CellAlignment::Left,
|
||||
Color::White,
|
||||
),
|
||||
OwnedValue::Integer(i) => {
|
||||
(i.to_string(), CellAlignment::Right)
|
||||
(i.to_string(), CellAlignment::Right, Color::DarkRed)
|
||||
}
|
||||
OwnedValue::Float(f) => {
|
||||
(f.to_string(), CellAlignment::Right)
|
||||
(f.to_string(), CellAlignment::Right, Color::DarkRed)
|
||||
}
|
||||
OwnedValue::Text(s) => {
|
||||
(s.to_string(), CellAlignment::Left, Color::DarkGreen)
|
||||
}
|
||||
OwnedValue::Text(s) => (s.to_string(), CellAlignment::Left),
|
||||
OwnedValue::Blob(b) => (
|
||||
String::from_utf8_lossy(b).to_string(),
|
||||
CellAlignment::Left,
|
||||
Color::DarkGreen,
|
||||
),
|
||||
_ => unreachable!(),
|
||||
};
|
||||
row.add_cell(Cell::new(content).set_alignment(alignment));
|
||||
row.add_cell(
|
||||
Cell::new(content).set_alignment(alignment).fg(color),
|
||||
);
|
||||
}
|
||||
table.add_row(row);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//! Build.rs script to generate a binary syntax set for syntect
|
||||
//! based on the SQL.sublime-syntax file.
|
||||
//! based on the SQL.sublime-syntax file.
|
||||
|
||||
use std::env;
|
||||
use std::path::Path;
|
||||
|
||||
Reference in New Issue
Block a user