apicurio_cli/commands/
init.rs1use anyhow::Result;
2use std::{fs, path::Path};
3
4use crate::constants::{APICURIO_CONFIG, APICURIO_LOCK};
5
6pub async fn run() -> Result<()> {
7 let cfg = Path::new(APICURIO_CONFIG);
8 if cfg.exists() {
9 println!("Config already exists at {}", cfg.display());
10 } else {
11 let template = r#"externalRegistriesFile: ${APICURIO_REGISTRIES_PATH:-}
12registries: []
13dependencies: []"#;
14 fs::write(cfg, template)?;
15 println!("Created {}", cfg.display());
16 }
17
18 let lock = Path::new(APICURIO_LOCK);
19 if !lock.exists() {
20 fs::write(lock, "lockedDependencies: []")?;
21 println!("Created {}", lock.display());
22 }
23
24 Ok(())
25}