ferro_cli/commands/
json_ui_schema.rs1use console::style;
2use std::path::Path;
3use std::process::Command;
4
5pub fn run(output: Option<String>, pretty: bool, component: Option<String>) {
11 if !Path::new("Cargo.toml").exists() {
12 eprintln!(
13 "{} This command must be run from a Ferro project root (no Cargo.toml found)",
14 style("Error:").red().bold()
15 );
16 std::process::exit(1);
17 }
18
19 let mut args: Vec<String> = vec![
20 "run".into(),
21 "--quiet".into(),
22 "--".into(),
23 "json-ui:schema".into(),
24 ];
25 if let Some(o) = output.as_deref() {
26 args.push("--output".into());
27 args.push(o.to_string());
28 }
29 if pretty {
30 args.push("--pretty".into());
31 }
32 if let Some(c) = component.as_deref() {
33 args.push("--component".into());
34 args.push(c.to_string());
35 }
36
37 let status = Command::new("cargo")
38 .args(&args)
39 .status()
40 .expect("Failed to execute cargo command");
41
42 if !status.success() {
43 eprintln!("{} Schema export failed", style("Error:").red().bold());
44 std::process::exit(1);
45 }
46}