app
Adom Chipsmith
Public Made by Adomby adom
STEP-native chip validator — 5-source cross-validation, OCCT-generated copyright-free 3D models with embedded signal annotations, datasheet-to-STEP pipeline.
use crate::cli::{err, ok, DEFAULT_PORT};
use anyhow::Result;
use clap::Parser;
use std::time::Duration;
#[derive(Parser)]
pub struct Args {
#[arg(long, default_value_t = DEFAULT_PORT)]
pub port: u16,
}
pub fn run(args: Args) -> Result<()> {
let url = format!("http://127.0.0.1:{}/state", args.port);
match ureq::get(&url).timeout(Duration::from_secs(2)).call() {
Ok(r) => {
let body: serde_json::Value = r.into_json()?;
ok(serde_json::to_string_pretty(&body).unwrap_or_default());
Ok(())
}
Err(e) => {
err(format!("not running on port {}: {e}", args.port));
Err(anyhow::anyhow!("not running"))
}
}
}