add validate command, remove Python dependency from CI

This commit is contained in:
Adil Hafeez 2026-03-22 23:09:56 +00:00
parent eb30c65796
commit 6efb152cec
4 changed files with 49 additions and 13 deletions

View file

@ -5,6 +5,7 @@ pub mod init;
pub mod logs;
pub mod self_update;
pub mod up;
pub mod validate;
use clap::{Parser, Subcommand};
@ -134,6 +135,16 @@ pub enum Command {
list_templates: bool,
},
/// Validate a Plano configuration file
Validate {
/// Config file path
file: Option<String>,
/// Path to the directory containing config.yaml
#[arg(long, default_value = ".")]
path: String,
},
/// Update planoai to the latest version
#[command(name = "self-update")]
SelfUpdate {
@ -261,6 +272,7 @@ pub async fn run(cli: Cli) -> anyhow::Result<()> {
force,
list_templates,
}) => init::run(template, clean, output, force, list_templates).await,
Some(Command::Validate { file, path }) => validate::run(file, &path).await,
Some(Command::SelfUpdate { version }) => self_update::run(version.as_deref()).await,
}
}

View file

@ -0,0 +1,31 @@
use anyhow::Result;
use crate::native::runner::validate_config;
use crate::utils::find_config_file;
pub async fn run(file: Option<String>, path: &str) -> Result<()> {
let green = console::Style::new().green();
let red = console::Style::new().red();
let config_path = find_config_file(path, file.as_deref());
if !config_path.exists() {
eprintln!(
"{} Config file not found: {}",
red.apply_to(""),
config_path.display()
);
std::process::exit(1);
}
match validate_config(&config_path) {
Ok(()) => {
eprintln!("{} Configuration valid", green.apply_to(""));
Ok(())
}
Err(e) => {
eprintln!("{} Validation failed", red.apply_to(""));
eprintln!(" {e:#}");
std::process::exit(1);
}
}
}