diff --git a/cuddle_cli/src/cli.rs b/cuddle_cli/src/cli.rs index 665acbf..8f3d661 100644 --- a/cuddle_cli/src/cli.rs +++ b/cuddle_cli/src/cli.rs @@ -35,7 +35,13 @@ impl CuddleAction { for (k, v) in args { let var = match v { CuddleShellScriptArg::Env(e) => { - let env_var = env::var(e.key.clone())?; + let env_var = match env::var(e.key.clone()) { + Ok(var) => var, + Err(e) => { + log::error!("env_variable not found: {}", k); + return Err(anyhow::anyhow!(e)); + } + }; CuddleVariable::new(k.clone(), env_var) } }; @@ -49,6 +55,8 @@ impl CuddleAction { let mut vars = variables.clone(); vars.append(&mut arg_variables); + log::trace!("preparing to run action"); + match actions::shell::ShellAction::new( self.name.clone(), format!( @@ -61,7 +69,10 @@ impl CuddleAction { ) .execute(vars) { - Ok(()) => Ok(()), + Ok(()) => { + log::trace!("finished running action"); + Ok(()) + } Err(e) => { log::error!("{}", e); Err(e) @@ -274,19 +285,19 @@ impl<'a> CuddleCli<'a> { match exe_submatch.subcommand() { Some((name, _action_matches)) => { - log::trace!(action=name; "running action"); + log::trace!(action=name; "running action; name={}", name); match self.scripts.iter().find(|ele| ele.name == name) { Some(script) => { - script.clone().execute(self.variables.clone()); + script.clone().execute(self.variables.clone())?; Ok(()) } - _ => (Err(anyhow!("could not find a match"))), + _ => Err(anyhow!("could not find a match")), } } - _ => (Err(anyhow!("could not find a match"))), + _ => Err(anyhow!("could not find a match")), } } - _ => (Err(anyhow!("could not find a match"))), + _ => Err(anyhow!("could not find a match")), }; match res { diff --git a/cuddle_cli/src/main.rs b/cuddle_cli/src/main.rs index f6e2699..dbc9cde 100644 --- a/cuddle_cli/src/main.rs +++ b/cuddle_cli/src/main.rs @@ -35,7 +35,7 @@ fn main() -> anyhow::Result<()> { fn init_logging() -> anyhow::Result<()> { tracing_subscriber::fmt() .pretty() - .with_max_level(Level::INFO) + .with_max_level(Level::TRACE) .init(); Ok(())