mirror of
https://github.com/harivansh-afk/sandbox-agent.git
synced 2026-04-17 11:04:58 +00:00
refactor: rename sandbox-daemon to sandbox-agent
This commit is contained in:
parent
f92ecd9b9a
commit
a49ea094f3
41 changed files with 808 additions and 134 deletions
|
|
@ -1,8 +1,12 @@
|
|||
use std::env;
|
||||
use std::fs;
|
||||
use std::io::Write;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt, EnvFilter};
|
||||
|
||||
fn main() {
|
||||
init_logging();
|
||||
let mut out: Option<PathBuf> = None;
|
||||
let mut stdout = false;
|
||||
let mut args = env::args().skip(1).peekable();
|
||||
|
|
@ -26,15 +30,30 @@ fn main() {
|
|||
}
|
||||
}
|
||||
|
||||
let schema = sandbox_daemon_openapi_gen::OPENAPI_JSON;
|
||||
let schema = sandbox_agent_openapi_gen::OPENAPI_JSON;
|
||||
if stdout {
|
||||
println!("{schema}");
|
||||
write_stdout(schema);
|
||||
return;
|
||||
}
|
||||
|
||||
let out = out.unwrap_or_else(|| PathBuf::from("openapi.json"));
|
||||
if let Err(err) = fs::write(&out, schema) {
|
||||
eprintln!("failed to write {}: {err}", out.display());
|
||||
tracing::error!(path = %out.display(), error = %err, "failed to write openapi schema");
|
||||
std::process::exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
fn init_logging() {
|
||||
let filter = EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("info"));
|
||||
tracing_subscriber::registry()
|
||||
.with(filter)
|
||||
.with(tracing_logfmt::builder().layer().with_writer(std::io::stderr))
|
||||
.init();
|
||||
}
|
||||
|
||||
fn write_stdout(text: &str) {
|
||||
let mut out = std::io::stdout();
|
||||
let _ = out.write_all(text.as_bytes());
|
||||
let _ = out.write_all(b"\n");
|
||||
let _ = out.flush();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue