diff options
author | Griffin Smith <root@gws.fyi> | 2022-10-10T23·41-0400 |
---|---|---|
committer | grfn <grfn@gws.fyi> | 2022-10-11T00·33+0000 |
commit | 1181bd78fc7d41a4786a0355244dbdee327560a7 (patch) | |
tree | 0a9903bd46a239bc9ceb6ce6c2ac448a1b6e3dce | |
parent | 4283f0139a82299c5240a25bb27ae84be3c99e13 (diff) |
feat(tvix/eval): Allow directly evaluating an expr via main r/5103
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 <tazjin@tvl.su> Tested-by: BuildkiteCI
-rw-r--r-- | tvix/eval/src/main.rs | 7 |
1 files changed, 7 insertions, 0 deletions
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<PathBuf>, + #[clap(long, short = 'E')] + expr: Option<String>, + #[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) } |