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::{eval, err, ok, DEFAULT_PORT};
use anyhow::Result;
use clap::Parser;
#[derive(Parser)]
pub struct Args {
/// View name: front | back | left | right | top | bottom | iso | home.
pub view: String,
#[arg(long, default_value_t = 5)]
pub timeout_secs: u64,
#[arg(long, default_value_t = DEFAULT_PORT)]
pub port: u16,
}
pub fn run(args: Args) -> Result<()> {
let v = args.view.trim().to_lowercase();
if !matches!(
v.as_str(),
"front" | "back" | "left" | "right" | "top" | "bottom" | "iso" | "home"
) {
err(format!("unknown view '{v}'"));
return Err(anyhow::anyhow!("bad view"));
}
let code = format!(
"return window.adomStep ? window.adomStep.setView({}) : {{ error: 'adomStep not loaded' }};",
serde_json::to_string(&v).unwrap()
);
eval::eval_snippet(&code, args.timeout_secs, args.port, true)?;
ok(format!("set view: {v}"));
Ok(())
}