Add --no-add-history flag
Flag prevents the input stream from saving terms to ~/.scryer_history when set. Use the flag when running tests to increase test isolation.
This commit is contained in:
16
src/machine/args.rs
Normal file
16
src/machine/args.rs
Normal file
@@ -0,0 +1,16 @@
|
||||
use std::collections::BTreeSet;
|
||||
use std::env;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct MachineArgs {
|
||||
pub add_history: bool,
|
||||
}
|
||||
|
||||
impl MachineArgs {
|
||||
pub fn new() -> Self {
|
||||
let args: BTreeSet<String> = env::args().collect();
|
||||
Self {
|
||||
add_history: !args.contains("--no-add-history"),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
pub mod args;
|
||||
pub mod arithmetic_ops;
|
||||
pub mod attributed_variables;
|
||||
pub mod code_walker;
|
||||
@@ -25,6 +26,7 @@ use crate::arithmetic::*;
|
||||
use crate::atom_table::*;
|
||||
use crate::forms::*;
|
||||
use crate::instructions::*;
|
||||
use crate::machine::args::*;
|
||||
use crate::machine::compile::*;
|
||||
use crate::machine::copier::*;
|
||||
use crate::machine::heap::*;
|
||||
@@ -396,9 +398,10 @@ impl Machine {
|
||||
pub fn new() -> Self {
|
||||
use ref_thread_local::RefThreadLocal;
|
||||
|
||||
let args = MachineArgs::new();
|
||||
let mut machine_st = MachineState::new();
|
||||
|
||||
let user_input = Stream::stdin(&mut machine_st.arena);
|
||||
let user_input = Stream::stdin(&mut machine_st.arena, args.add_history);
|
||||
let user_output = Stream::stdout(&mut machine_st.arena);
|
||||
let user_error = Stream::stderr(&mut machine_st.arena);
|
||||
|
||||
|
||||
@@ -426,9 +426,9 @@ impl Stream {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn stdin(arena: &mut Arena) -> Stream {
|
||||
pub fn stdin(arena: &mut Arena, add_history: bool) -> Stream {
|
||||
Stream::Readline(arena_alloc!(
|
||||
StreamLayout::new(ReadlineStream::new("")),
|
||||
StreamLayout::new(ReadlineStream::new("", add_history)),
|
||||
arena
|
||||
))
|
||||
}
|
||||
|
||||
@@ -4094,7 +4094,7 @@ impl Machine {
|
||||
match result {
|
||||
Ok(()) => Ok(()),
|
||||
Err(e) => {
|
||||
self.user_input = input_stream(&mut self.machine_st.arena);
|
||||
self.user_input.reset();
|
||||
return Err(e);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user