git.delta.rocks / jrsonnet / refs/commits / 295345aa77d8

difftreelog

feat add -c, -o, -m flags

Lach2020-08-26parent: #946acf9.patch.diff
in: master

3 files changed

modifiedCargo.lockdiffbeforeafterboth
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -148,6 +148,7 @@
  "jrsonnet-evaluator",
  "jrsonnet-parser",
  "mimallocator",
+ "thiserror",
 ]
 
 [[package]]
@@ -176,6 +177,7 @@
  "serde",
  "serde_json",
  "structdump",
+ "thiserror",
 ]
 
 [[package]]
@@ -429,6 +431,26 @@
 ]
 
 [[package]]
+name = "thiserror"
+version = "1.0.20"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7dfdd070ccd8ccb78f4ad66bf1982dc37f620ef696c6b5028fe2ed83dd3d0d08"
+dependencies = [
+ "thiserror-impl",
+]
+
+[[package]]
+name = "thiserror-impl"
+version = "1.0.20"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bd80fc12f73063ac132ac92aceea36734f04a1d93c1240c6944e23a3b8841793"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
 name = "unescape"
 version = "0.1.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
modifiedcmds/jrsonnet/Cargo.tomldiffbeforeafterboth
--- a/cmds/jrsonnet/Cargo.toml
+++ b/cmds/jrsonnet/Cargo.toml
@@ -19,6 +19,7 @@
 jrsonnet-cli = { path = "../../crates/jrsonnet-cli", version = "0.1.0" }
 # TODO: Fix mimalloc compile errors, and use them
 mimallocator = { version = "0.1.3", optional = true }
+thiserror = "1.0.20"
 
 [dependencies.clap]
 git = "https://github.com/clap-rs/clap"
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.14	/// This shouldn't be changed unless jrsonnet is failing with stack overflow error.15	#[clap(long, name = "size")]16	pub os_stack: Option<usize>,17}1819#[derive(Clap)]20struct Opts {21	#[clap(flatten)]22	input: InputOpts,23	#[clap(flatten)]24	general: GeneralOpts,25	#[clap(flatten)]26	manifest: ManifestOpts,27	#[clap(flatten)]28	debug: DebugOpts,29}3031fn main() {32	let opts: Opts = Opts::parse();33	if let Some(size) = opts.debug.os_stack {34		std::thread::Builder::new()35			.stack_size(size * 1024 * 1024)36			.spawn(|| main_catch(opts))37			.expect("new thread spawned")38			.join()39			.expect("thread finished successfully");40	} else {41		main_catch(opts)42	}43}4445fn main_catch(opts: Opts) {46	let state = EvaluationState::default();47	if let Err(e) = main_real(&state, opts) {48		println!("{}", state.stringify_err(&e));49	}50}5152fn main_real(state: &EvaluationState, opts: Opts) -> Result<()> {53	opts.general.configure(&state)?;54	opts.manifest.configure(&state)?;5556	let val = if opts.input.exec {57		state.evaluate_snippet_raw(58			Rc::new(PathBuf::from("args")),59			(&opts.input.input as &str).into(),60		)?61	} else {62		state.evaluate_file_raw(&PathBuf::from(opts.input.input))?63	};6465	let val = state.with_tla(val)?;6667	println!("{}", state.manifest(val)?);6869	Ok(())70}