disable adaptive colors when output_mode is list

This commit is contained in:
meteorgan 2025-07-03 23:31:51 +08:00
parent 9e92325bad
commit ccfee3f418
2 changed files with 15 additions and 1 deletions

View file

@ -151,6 +151,7 @@ impl Limbo {
}
let sql = opts.sql.clone();
let quiet = opts.quiet;
let config = Config::for_output_mode(opts.output_mode);
let mut app = Self {
prompt: PROMPT.to_string(),
io,
@ -160,7 +161,7 @@ impl Limbo {
input_buff: String::new(),
opts: Settings::from(opts),
rl: None,
config: Some(Config::default()),
config: Some(config),
};
app.first_run(sql, quiet)?;
Ok(app)

View file

@ -1,6 +1,7 @@
mod palette;
mod terminal;
use crate::input::OutputMode;
use crate::HOME_DIR;
use nu_ansi_term::Color;
use palette::LimboColor;
@ -79,6 +80,18 @@ impl Config {
None
}
}
pub fn for_output_mode(mode: OutputMode) -> Self {
let table = if mode == OutputMode::Pretty {
TableConfig::adaptive_colors()
} else {
TableConfig::no_colors()
};
Self {
table,
highlight: HighlightConfig::default(),
}
}
}
#[derive(Debug, Deserialize, Clone, JsonSchema, Validate)]