v0.2.14 : aide Nushell, themes de couleurs et cadres blancs
- Aide facon Nushell : help <cmd>, <cmd> -h/--help, help, help commands, help --find <texte>, help <agent> (fiche info) - sections Usage/Flags/ Command Type/Parameters/Input-output/Examples avec couleurs - Commande version : tableau Nushell (commit, build, rustc, theme...) + --json ; build.rs pour commit/branche git ; -V reste la version courte - Themes : --theme <nom> (default, ocean, sunset, forest, dracula, mono) + settings.theme dans la config ; activation VT Windows pour les couleurs - Cadres blancs Nushell partages : list, search, status, doctor, ls/ps/ where/get et menu d autocompletion Tab encadre (colonnes name/description)
This commit is contained in:
+36
-11
@@ -58,6 +58,26 @@ impl DataTable {
|
||||
/// truncated with an ellipsis and the trailing columns are dropped if
|
||||
/// that is still not enough — every row stays on a single line.
|
||||
pub fn render(&self, color: bool, max_width: usize) -> String {
|
||||
self.render_with(None, color, max_width)
|
||||
}
|
||||
|
||||
/// Render with the colors of a theme (borders dimmed, header row in the
|
||||
/// theme's header style instead of plain bold).
|
||||
pub fn render_themed(
|
||||
&self,
|
||||
theme: &crate::theme::Theme,
|
||||
color: bool,
|
||||
max_width: usize,
|
||||
) -> String {
|
||||
self.render_with(Some(theme), color, max_width)
|
||||
}
|
||||
|
||||
fn render_with(
|
||||
&self,
|
||||
theme: Option<&crate::theme::Theme>,
|
||||
color: bool,
|
||||
max_width: usize,
|
||||
) -> String {
|
||||
let max_width = max_width.max(20);
|
||||
let headers = self.columns.clone();
|
||||
if headers.is_empty() {
|
||||
@@ -133,13 +153,16 @@ impl DataTable {
|
||||
line.push(right);
|
||||
line
|
||||
};
|
||||
let row_line = |row: &[String], bold: bool| -> String {
|
||||
let row_line = |row: &[String], header: bool| -> String {
|
||||
let mut line = String::from("│");
|
||||
for (i, c) in row.iter().enumerate().take(all_widths.len()) {
|
||||
line.push(' ');
|
||||
let cell = fit_cell(c, all_widths[i]);
|
||||
let rendered = if bold {
|
||||
cell.bold().to_string()
|
||||
let rendered = if header {
|
||||
match theme {
|
||||
Some(t) if color => t.hdr(&cell),
|
||||
_ => cell.bold().to_string(),
|
||||
}
|
||||
} else {
|
||||
cell
|
||||
};
|
||||
@@ -149,26 +172,28 @@ impl DataTable {
|
||||
}
|
||||
line
|
||||
};
|
||||
let dim = |s: &str| -> String {
|
||||
if color {
|
||||
s.dimmed().to_string()
|
||||
} else {
|
||||
s.to_string()
|
||||
let edge = |s: &str| -> String {
|
||||
if !color {
|
||||
return s.to_string();
|
||||
}
|
||||
match theme {
|
||||
Some(t) => t.dimmed(s),
|
||||
None => s.dimmed().to_string(),
|
||||
}
|
||||
};
|
||||
|
||||
let mut out = String::new();
|
||||
out.push_str(&dim(&border('╭', '┬', '╮')));
|
||||
out.push_str(&edge(&border('╭', '┬', '╮')));
|
||||
out.push('\n');
|
||||
out.push_str(&row_line(&all_headers, true));
|
||||
out.push('\n');
|
||||
out.push_str(&dim(&border('├', '┼', '┤')));
|
||||
out.push_str(&edge(&border('├', '┼', '┤')));
|
||||
out.push('\n');
|
||||
for line in &cells {
|
||||
out.push_str(&row_line(line, false));
|
||||
out.push('\n');
|
||||
}
|
||||
out.push_str(&dim(&border('╰', '┴', '╯')));
|
||||
out.push_str(&edge(&border('╰', '┴', '╯')));
|
||||
out.push('\n');
|
||||
out
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user