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:
parent
70c4b512c2
commit
55ec06b26b
1 changed files with 4 additions and 0 deletions
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue