#[cfg(windows)]
fn main() -> anyhow::Result<()> {
let code = std::thread::Builder::new()
.name("ambient-brush".into())
.stack_size(8 * 1024 * 1024)
.spawn(|| {
tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()?
.block_on(run())
})?
.join()
.map_err(|_| anyhow::anyhow!("ambient Brush worker panicked"))??;
std::process::exit(code);
}
#[cfg(not(windows))]
fn main() {
eprintln!("newt-ambient-brush is supported on Windows only");
std::process::exit(1);
}
#[cfg(windows)]
async fn run() -> anyhow::Result<i32> {
use std::io::Read;
let mut input = String::new();
std::io::stdin().read_to_string(&mut input)?;
let script: String = serde_json::from_str(&input)?;
let mut shell = brush_core::Shell::builder()
.builtins(brush_builtins::default_builtins(
brush_builtins::BuiltinSet::BashMode,
))
.interactive(false)
.no_editing(true)
.kill_external_commands_on_drop(true)
.build()
.await?;
let params = shell.default_exec_params();
let result = shell
.run_string(&script, &brush_core::SourceInfo::default(), ¶ms)
.await?;
Ok(u8::from(result.exit_code) as i32)
}