Skip to main content

entrenar/cli/commands/
info.rs

1//! Info command implementation
2
3use crate::cli::logging::log;
4use crate::cli::LogLevel;
5use crate::config::{load_config, InfoArgs, OutputFormat};
6
7pub fn run_info(args: InfoArgs, level: LogLevel) -> Result<(), String> {
8    let spec = load_config(&args.config).map_err(|e| format!("Config error: {e}"))?;
9
10    match args.format {
11        OutputFormat::Text => {
12            log(level, LogLevel::Normal, "Configuration Info:");
13            println!();
14            println!("Model: {}", spec.model.path.display());
15            println!("Optimizer: {} (lr={})", spec.optimizer.name, spec.optimizer.lr);
16            println!("Epochs: {}", spec.training.epochs);
17            println!("Batch size: {}", spec.data.batch_size);
18
19            if spec.lora.is_some() {
20                println!("LoRA: enabled");
21            }
22            if spec.quantize.is_some() {
23                println!("Quantization: enabled");
24            }
25        }
26        OutputFormat::Json => {
27            let json = serde_json::to_string_pretty(&spec)
28                .map_err(|e| format!("JSON serialization error: {e}"))?;
29            println!("{json}");
30        }
31        OutputFormat::Yaml => {
32            let yaml = serde_yaml::to_string(&spec)
33                .map_err(|e| format!("YAML serialization error: {e}"))?;
34            println!("{yaml}");
35        }
36    }
37
38    Ok(())
39}