mecha10_cli/dev/
validation.rs1use crate::paths;
4use anyhow::{anyhow, Result};
5use std::path::Path;
6
7pub fn check_project_initialized(project_root: &Path) -> Result<()> {
9 let config_file = project_root.join(paths::PROJECT_CONFIG);
10
11 if !config_file.exists() {
12 return Err(anyhow!(
13 "Not in a Mecha10 project directory.\n\
14 Run 'mecha10 init' to create a new project."
15 ));
16 }
17
18 Ok(())
19}
20
21pub fn validate_node_names(requested_nodes: &[String], available_nodes: &[String]) -> Result<Vec<String>> {
23 let mut invalid = Vec::new();
24
25 for node in requested_nodes {
26 if !available_nodes.contains(node) {
27 invalid.push(node.clone());
28 }
29 }
30
31 if !invalid.is_empty() {
32 return Err(anyhow!(
33 "Unknown nodes: {}\nAvailable nodes: {}",
34 invalid.join(", "),
35 available_nodes.join(", ")
36 ));
37 }
38
39 Ok(requested_nodes.to_vec())
40}