Skip to content

Commit 1018103

Browse files
committed
fix: escape command-line args in log
1 parent e88a709 commit 1018103

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

src/linter.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,11 @@ impl Linter {
8585
"Running linter {}: {} {}",
8686
self.code,
8787
program[0],
88-
arguments.join(" ")
88+
arguments
89+
.iter()
90+
.map(|x| format!("'{x}'"))
91+
.collect::<Vec<_>>()
92+
.join(" ")
8993
);
9094

9195
let start = std::time::Instant::now();

src/rage.rs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
use crate::persistent_data::PersistentDataStore;
2+
use anyhow::Result;
3+
use console::style;
4+
use dialoguer::{theme::ColorfulTheme, Select};
5+
6+
pub fn do_rage(
7+
persistent_data_store: &PersistentDataStore,
8+
invocation: Option<usize>,
9+
) -> Result<i32> {
10+
let run = match invocation {
11+
Some(invocation) => Some(persistent_data_store.run(invocation)?),
12+
None => {
13+
let runs = persistent_data_store.runs()?;
14+
let items: Vec<String> = persistent_data_store
15+
.runs()?
16+
.iter()
17+
.map(|run| run.timestamp.to_string() + ": " + &run.args.join(" "))
18+
.collect();
19+
20+
let selection = Select::with_theme(&ColorfulTheme::default())
21+
.with_prompt("Select a past invocation to report")
22+
.items(&items)
23+
.default(0)
24+
.interact_opt()?;
25+
26+
selection.map(|i| runs.into_iter().nth(i).unwrap())
27+
}
28+
};
29+
30+
match run {
31+
Some(run) => {
32+
let report = persistent_data_store.get_run_report(&run)?;
33+
print!("{}", report);
34+
Ok(0)
35+
}
36+
None => {
37+
println!("{}", style("Nothing selected, exiting.").yellow());
38+
Ok(1)
39+
}
40+
}
41+
}

0 commit comments

Comments
 (0)