git.delta.rocks / jrsonnet / refs/commits / 6c1a2fa6d186

difftreelog

docs fix `DebugOpts`

progrm_jarvis2020-08-03parent: #656c8fd.patch.diff
in: master

1 file changed

modifiedcmds/jrsonnet/src/main.rsdiffbeforeafterboth
before · cmds/jrsonnet/src/main.rs
1use clap::Clap;2use jrsonnet_cli::{ConfigureState, GeneralOpts, InputOpts, ManifestOpts};3use jrsonnet_evaluator::{error::Result, EvaluationState};4use std::{path::PathBuf, rc::Rc};56#[cfg(feature = "mimalloc")]7#[global_allocator]8static GLOBAL: mimallocator::Mimalloc = mimallocator::Mimalloc;910#[derive(Clap)]11// #[clap(help_heading = "DEBUG")]12struct DebugOpts {13	/// Required OS stack size, probally you shouldn't change it, unless jrsonnet is failing with stack overflow14	#[clap(long, name = "size")]15	pub os_stack: Option<usize>,16}1718#[derive(Clap)]19struct Opts {20	#[clap(flatten)]21	input: InputOpts,22	#[clap(flatten)]23	general: GeneralOpts,24	#[clap(flatten)]25	manifest: ManifestOpts,26	#[clap(flatten)]27	debug: DebugOpts,28}2930fn main() {31	let opts: Opts = Opts::parse();32	if let Some(size) = opts.debug.os_stack {33		std::thread::Builder::new()34			.stack_size(size * 1024 * 1024)35			.spawn(|| main_catch(opts))36			.expect("new thread spawned")37			.join()38			.expect("thread finished successfully");39	} else {40		main_catch(opts)41	}42}4344fn main_catch(opts: Opts) {45	let state = EvaluationState::default();46	if let Err(e) = main_real(&state, opts) {47		println!("{}", state.stringify_err(&e));48	}49}5051fn main_real(state: &EvaluationState, opts: Opts) -> Result<()> {52	opts.general.configure(&state)?;53	opts.manifest.configure(&state)?;5455	let val = if opts.input.evaluate {56		state.evaluate_snippet_raw(57			Rc::new(PathBuf::from("args")),58			(&opts.input.input as &str).into(),59		)?60	} else {61		state.evaluate_file_raw(&PathBuf::from(opts.input.input))?62	};6364	let val = state.with_tla(val)?;6566	println!("{}", state.manifest(val)?);6768	Ok(())69}