about summary refs log tree commit diff
path: root/tvix/eval
diff options
context:
space:
mode:
authorGriffin Smith <root@gws.fyi>2022-10-10T23·41-0400
committergrfn <grfn@gws.fyi>2022-10-11T00·33+0000
commit1181bd78fc7d41a4786a0355244dbdee327560a7 (patch)
tree0a9903bd46a239bc9ceb6ce6c2ac448a1b6e3dce /tvix/eval
parent4283f0139a82299c5240a25bb27ae84be3c99e13 (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
Diffstat (limited to 'tvix/eval')
-rw-r--r--tvix/eval/src/main.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/tvix/eval/src/main.rs b/tvix/eval/src/main.rs
index d70d82f68f..22bea16d0e 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)
     }