refactor: Enhance table generation and clean up dependencies
Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
This commit is contained in:
@@ -3,13 +3,13 @@ use crate::compression_engine::CompressionType;
|
||||
use crate::meta_plugin::MetaPluginType;
|
||||
use clap::Command;
|
||||
use clap::error::ErrorKind;
|
||||
use comfy_table::{Table, ContentArrangement};
|
||||
use log::debug;
|
||||
use regex::Regex;
|
||||
use std::collections::HashMap;
|
||||
use std::env;
|
||||
use std::str::FromStr;
|
||||
use strum::IntoEnumIterator;
|
||||
use termsize;
|
||||
#[derive(Debug, Clone, strum::EnumString, strum::Display, PartialEq)]
|
||||
#[strum(ascii_case_insensitive)]
|
||||
pub enum OutputFormat {
|
||||
@@ -142,3 +142,20 @@ pub fn settings_output_format(settings: &config::Settings) -> OutputFormat {
|
||||
.unwrap_or(OutputFormat::Table)
|
||||
}
|
||||
|
||||
/// Create a table with consistent styling and terminal detection
|
||||
pub fn create_table(use_styling: bool) -> Table {
|
||||
let mut table = Table::new();
|
||||
table.set_content_arrangement(ContentArrangement::Dynamic);
|
||||
|
||||
if use_styling {
|
||||
table
|
||||
.load_preset(comfy_table::presets::UTF8_FULL)
|
||||
.apply_modifier(comfy_table::modifiers::UTF8_ROUND_CORNERS);
|
||||
} else {
|
||||
table.load_preset(comfy_table::presets::NOTHING);
|
||||
}
|
||||
|
||||
table.force_no_tty_if(!std::io::stdout().is_terminal());
|
||||
table
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user