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

@@ -12,10 +12,17 @@ use crate::{
model::{CuddleBase, CuddlePlan},
};
#[derive(Debug, Clone, PartialEq)]
pub enum CuddleTreeType {
Root,
Leaf,
}
#[derive(Debug)]
pub struct CuddleContext {
pub plan: CuddlePlan,
pub path: PathBuf,
pub node_type: CuddleTreeType,
}
pub fn extract_cuddle(config: CuddleConfig) -> anyhow::Result<Arc<Mutex<Vec<CuddleContext>>>> {
@@ -41,6 +48,7 @@ pub fn extract_cuddle(config: CuddleConfig) -> anyhow::Result<Arc<Mutex<Vec<Cudd
context.lock().unwrap().push(CuddleContext {
plan: cuddle_plan.clone(),
path: current_dir()?,
node_type: CuddleTreeType::Root,
});
// pull parent plan and execute recursive descent
@@ -131,6 +139,7 @@ fn recurse_parent(path: PathBuf, context: Arc<Mutex<Vec<CuddleContext>>>) -> any
ctxs.push(CuddleContext {
plan: cuddle_plan.clone(),
path: path.clone(),
node_type: CuddleTreeType::Leaf,
});
} else {
return Err(anyhow::anyhow!("Could not acquire lock, aborting"));