Files
radicle-explorer/crates/test-http-api/src/main.rs
T
Sebastian Martinez d90dc0735c Add test-http-api crate to make app work in browser
A new `invoke` function calls either the tauri backend or the
`test-http-api` function if ran in a browser.
2024-10-28 13:56:23 +01:00

36 lines
804 B
Rust

use std::process;
use test_http_api as api;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let options = parse_options()?;
match api::run(options).await {
Ok(()) => {}
Err(_) => {
process::exit(1);
}
}
Ok(())
}
fn parse_options() -> Result<api::Options, lexopt::Error> {
use lexopt::prelude::*;
let mut parser = lexopt::Parser::from_env();
let mut listen = None;
while let Some(arg) = parser.next()? {
match arg {
Long("listen") => {
let addr = parser.value()?.parse()?;
listen = Some(addr);
}
_ => return Err(arg.unexpected()),
}
}
Ok(api::Options {
listen: listen.unwrap_or_else(|| ([0, 0, 0, 0], 8080).into()),
})
}