From 1181bd78fc7d41a4786a0355244dbdee327560a7 Mon Sep 17 00:00:00 2001 From: Griffin Smith Date: Mon, 10 Oct 2022 19:41:42 -0400 Subject: feat(tvix/eval): Allow directly evaluating an expr via main This *maybe* should do something to check that we don't pass both a file and an expr, but for now this is useful enough to cut corners (plus we're probably due for a CLI revamp eventually anyway). Change-Id: Id44357074150b336b6215ba596cc52d01d037dbd Reviewed-on: https://cl.tvl.fyi/c/depot/+/6941 Reviewed-by: tazjin Tested-by: BuildkiteCI --- tvix/eval/src/main.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tvix/eval') diff --git a/tvix/eval/src/main.rs b/tvix/eval/src/main.rs index d70d82f68f8a..22bea16d0e20 100644 --- a/tvix/eval/src/main.rs +++ b/tvix/eval/src/main.rs @@ -8,6 +8,9 @@ struct Args { /// Path to a script to evaluate script: Option, + #[clap(long, short = 'E')] + expr: Option, + #[clap(flatten)] eval_options: tvix_eval::Options, } @@ -17,6 +20,10 @@ fn main() { if let Some(file) = args.script { run_file(file, args.eval_options) + } else if let Some(expr) = args.expr { + if let Ok(result) = tvix_eval::interpret(&expr, None, args.eval_options) { + println!("=> {} :: {}", result, result.type_of()) + } } else { run_prompt(args.eval_options) } -- cgit 1.4.1