add bare cli

This commit is contained in:
2022-08-11 02:03:19 +02:00
parent ba0ad9239d
commit 5da6b35ead
6 changed files with 185 additions and 38 deletions

View File

@@ -1,8 +1,8 @@
use std::{
io::{BufRead, BufReader},
process::{Command, Stdio},
};
use std::process::Command;
use crate::cli::CuddleVariable;
#[allow(dead_code)]
pub struct ShellAction {
path: String,
name: String,
@@ -13,7 +13,7 @@ impl ShellAction {
Self { path, name }
}
pub fn execute(self) -> anyhow::Result<()> {
pub fn execute(self, variables: Vec<CuddleVariable>) -> anyhow::Result<()> {
log::debug!("executing shell action: {}", self.path.clone());
log::info!(
@@ -28,18 +28,12 @@ Starting running shell action: {}
let mut process = Command::new(self.path)
.current_dir(".")
//.stdout(Stdio::piped())
//.stderr(Stdio::piped())
.spawn()?;
.envs(variables.iter().map(|v| {
log::trace!("{:?}", v);
//{
// let stdout = process.stdout.as_mut().unwrap();
// let stdout_reader = BufReader::new(stdout);
// let mut stdout_lines = stdout_reader.lines();
// while let Some(Ok(line)) = stdout_lines.next() {
// log::info!("{}", line);
// }
//}
(v.name.to_uppercase(), v.value.clone())
}))
.spawn()?;
process.wait()?;