tui: include optional full command line in history display (#2334)
Add env var to show the raw, unparsed command line under parsed commands. When we have transcript mode we should show the full command there, but this is useful for debugging.
This commit is contained in:
@@ -31,6 +31,7 @@ use ratatui::style::Style;
|
||||
use ratatui::widgets::Paragraph;
|
||||
use ratatui::widgets::WidgetRef;
|
||||
use ratatui::widgets::Wrap;
|
||||
use shlex::try_join as shlex_try_join;
|
||||
use std::collections::HashMap;
|
||||
use std::io::Cursor;
|
||||
use std::path::PathBuf;
|
||||
@@ -232,10 +233,11 @@ fn exec_command_lines(
|
||||
) -> Vec<Line<'static>> {
|
||||
match parsed.is_empty() {
|
||||
true => new_exec_command_generic(command, output, start_time),
|
||||
false => new_parsed_command(parsed, output, start_time),
|
||||
false => new_parsed_command(command, parsed, output, start_time),
|
||||
}
|
||||
}
|
||||
fn new_parsed_command(
|
||||
command: &[String],
|
||||
parsed_commands: &[ParsedCommand],
|
||||
output: Option<&CommandOutput>,
|
||||
start_time: Option<Instant>,
|
||||
@@ -260,6 +262,24 @@ fn new_parsed_command(
|
||||
}
|
||||
};
|
||||
|
||||
// Optionally include the complete, unaltered command from the model.
|
||||
if std::env::var("SHOW_FULL_COMMANDS")
|
||||
.map(|v| !v.is_empty())
|
||||
.unwrap_or(false)
|
||||
{
|
||||
let full_cmd = shlex_try_join(command.iter().map(|s| s.as_str()))
|
||||
.unwrap_or_else(|_| command.join(" "));
|
||||
lines.push(Line::from(vec![
|
||||
Span::styled(" └ ", Style::default().add_modifier(Modifier::DIM)),
|
||||
Span::styled(
|
||||
full_cmd,
|
||||
Style::default()
|
||||
.add_modifier(Modifier::DIM)
|
||||
.add_modifier(Modifier::ITALIC),
|
||||
),
|
||||
]));
|
||||
}
|
||||
|
||||
for (i, parsed) in parsed_commands.iter().enumerate() {
|
||||
let text = match parsed {
|
||||
ParsedCommand::Read { name, .. } => format!("📖 {name}"),
|
||||
|
||||
Reference in New Issue
Block a user