From 55ec06b26b3919c30751c67b0c40c5840aa1ca38 Mon Sep 17 00:00:00 2001 From: Aspen Smith Date: Mon, 27 May 2024 16:14:21 -0400 Subject: [PATCH] feat(tvix/repl): Implement :q, to quit Change-Id: Ib3b314b21f4d8c30bfd674e79771179d51d4f2e9 Reviewed-on: https://cl.tvl.fyi/c/depot/+/11736 Autosubmit: aspen Reviewed-by: flokli Tested-by: BuildkiteCI --- tvix/cli/src/repl.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tvix/cli/src/repl.rs b/tvix/cli/src/repl.rs index 7d29ae3d2..50c1779b0 100644 --- a/tvix/cli/src/repl.rs +++ b/tvix/cli/src/repl.rs @@ -18,12 +18,15 @@ fn state_dir() -> Option { pub enum ReplCommand<'a> { Expr(&'a str), Explain(&'a str), + Quit, } impl<'a> ReplCommand<'a> { pub fn parse(input: &'a str) -> Self { if let Some(without_prefix) = input.strip_prefix(":d ") { Self::Explain(without_prefix) + } else if input.trim_end() == ":q" { + Self::Quit } else { Self::Expr(input) } @@ -87,6 +90,7 @@ impl Repl { }; let res = match ReplCommand::parse(input) { + ReplCommand::Quit => break, ReplCommand::Expr(input) => interpret( Rc::clone(&io_handle), input,