feat(tvix/repl): Implement :q, to quit

Change-Id: Ib3b314b21f4d8c30bfd674e79771179d51d4f2e9
Reviewed-on: https://cl.tvl.fyi/c/depot/+/11736
Autosubmit: aspen <root@gws.fyi>
Reviewed-by: flokli <flokli@flokli.de>
Tested-by: BuildkiteCI
This commit is contained in:
Aspen Smith 2024-05-27 16:14:21 -04:00 committed by clbot
parent 70c4b512c2
commit 55ec06b26b

View file

@ -18,12 +18,15 @@ fn state_dir() -> Option<PathBuf> {
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,