debug log

This commit is contained in:
zjp 2023-05-13 22:41:02 +08:00
parent 25792db877
commit b9283f6718
6 changed files with 21 additions and 17 deletions

View file

@ -41,9 +41,10 @@ fn prompt_finder(
} }
} }
let child = shell::out() let mut cmd = shell::out();
.stdout(Stdio::piped()) cmd.stdout(Stdio::piped()).arg(suggestion_command);
.arg(suggestion_command) debug!(cmd = ?cmd);
let child = cmd
.spawn() .spawn()
.map_err(|e| ShellSpawnError::new(suggestion_command, e))?; .map_err(|e| ShellSpawnError::new(suggestion_command, e))?;
@ -236,9 +237,10 @@ pub fn act(
clipboard::copy(interpolated_snippet)?; clipboard::copy(interpolated_snippet)?;
} }
_ => { _ => {
shell::out() let mut cmd = shell::out();
.arg(&interpolated_snippet[..]) cmd.arg(&interpolated_snippet[..]);
.spawn() debug!(cmd = ?cmd);
cmd.spawn()
.map_err(|e| ShellSpawnError::new(&interpolated_snippet[..], e))? .map_err(|e| ShellSpawnError::new(&interpolated_snippet[..], e))?
.wait() .wait()
.context("bash was not running")?; .context("bash was not running")?;

View file

@ -13,6 +13,7 @@ use crate::welcome;
pub fn init(fetcher: Box<dyn Fetcher>) -> Result<()> { pub fn init(fetcher: Box<dyn Fetcher>) -> Result<()> {
let config = &CONFIG; let config = &CONFIG;
let opts = FinderOpts::snippet_default(); let opts = FinderOpts::snippet_default();
debug!("opts = {opts:#?}");
// let fetcher = config.fetcher(); // let fetcher = config.fetcher();
let (raw_selection, (variables, files)) = config let (raw_selection, (variables, files)) = config
@ -32,6 +33,7 @@ pub fn init(fetcher: Box<dyn Fetcher>) -> Result<()> {
}) })
.context("Failed getting selection and variables from finder")?; .context("Failed getting selection and variables from finder")?;
debug!(raw_selection = ?raw_selection);
let extractions = deser::terminal::read(&raw_selection, config.best_match()); let extractions = deser::terminal::read(&raw_selection, config.best_match());
if extractions.is_err() { if extractions.is_err() {
@ -45,7 +47,7 @@ pub fn init(fetcher: Box<dyn Fetcher>) -> Result<()> {
pub fn get_fetcher() -> Result<Box<dyn Fetcher>> { pub fn get_fetcher() -> Result<Box<dyn Fetcher>> {
let source = CONFIG.source(); let source = CONFIG.source();
debug!("{source:#?}"); debug!(source = ?source);
match source { match source {
Source::Cheats(query) => { Source::Cheats(query) => {
let lines = cheatsh::call(&query)?; let lines = cheatsh::call(&query)?;

View file

@ -30,11 +30,10 @@ impl Runnable for Input {
if !extra.is_empty() { if !extra.is_empty() {
print!(""); print!("");
shell::out() let mut cmd = shell::out();
.arg(extra) cmd.arg(extra);
.spawn() debug!(?cmd);
.map_err(|e| ShellSpawnError::new(extra, e))? cmd.spawn().map_err(|e| ShellSpawnError::new(extra, e))?.wait()?;
.wait()?;
} }
} }

View file

@ -42,6 +42,5 @@ pub fn out() -> Command {
cmd.args(words); cmd.args(words);
let dash_c = if words_str.contains("cmd.exe") { "/c" } else { "-c" }; let dash_c = if words_str.contains("cmd.exe") { "/c" } else { "-c" };
cmd.arg(dash_c); cmd.arg(dash_c);
debug!("shell cmd = `{cmd:#?}`");
cmd cmd
} }

View file

@ -190,7 +190,7 @@ impl fetcher::Fetcher for Fetcher {
} }
} }
debug!("{self:#?}"); debug!("FilesystemFetcher = {self:#?}");
Ok(found_something) Ok(found_something)
} }

View file

@ -152,11 +152,13 @@ impl FinderChoice {
}); });
} }
let child = command command
.env("SHELL", CONFIG.finder_shell()) .env("SHELL", CONFIG.finder_shell())
.stdin(Stdio::piped()) .stdin(Stdio::piped())
.stdout(Stdio::piped()) .stdout(Stdio::piped());
.spawn(); debug!(cmd = ?command);
let child = command.spawn();
let mut child = match child { let mut child = match child {
Ok(x) => x, Ok(x) => x,