From d3b618e943ca32527e749102f99059ca5bd5641c Mon Sep 17 00:00:00 2001 From: Michael Benfield Date: Wed, 11 Dec 2024 15:40:10 -0800 Subject: [PATCH] tui command line flag --- interpreter/src/lib.rs | 7 ++++--- leo/cli/commands/debug.rs | 7 +++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/interpreter/src/lib.rs b/interpreter/src/lib.rs index da5a0b426a..cdbd9d6ac6 100644 --- a/interpreter/src/lib.rs +++ b/interpreter/src/lib.rs @@ -45,7 +45,7 @@ mod value; use value::*; mod ui; -use ui::Ui as _; +use ui::Ui; mod dialoguer_input; @@ -125,11 +125,12 @@ pub fn interpret( aleo_filenames: &[PathBuf], signer: SvmAddress, block_height: u32, + tui: bool, ) -> Result<()> { let mut interpreter = Interpreter::new(leo_filenames.iter(), aleo_filenames.iter(), signer, block_height)?; - // let mut user_interface = dialoguer_input::DialoguerUi::new(); - let mut user_interface = ratatui_ui::RatatuiUi::new(); + let mut user_interface: Box = + if tui { Box::new(ratatui_ui::RatatuiUi::new()) } else { Box::new(dialoguer_input::DialoguerUi::new()) }; let mut code = String::new(); let mut futures = Vec::new(); diff --git a/leo/cli/commands/debug.rs b/leo/cli/commands/debug.rs index daac18a709..53a24ba47f 100644 --- a/leo/cli/commands/debug.rs +++ b/leo/cli/commands/debug.rs @@ -36,6 +36,9 @@ pub struct LeoDebug { #[arg(long, help = "The block height, accessible via block.height.", default_value = "0")] pub(crate) block_height: u32, + #[arg(long, action, help = "Use the text user interface.")] + pub(crate) tui: bool, + #[clap(flatten)] pub(crate) compiler_options: BuildOptions, } @@ -128,7 +131,7 @@ fn handle_debug(command: &LeoDebug, context: Context) -> Result<()> Vec::new() }; - leo_interpreter::interpret(&paths, &aleo_paths, address, command.block_height) + leo_interpreter::interpret(&paths, &aleo_paths, address, command.block_height, command.tui) } else { let private_key: PrivateKey = PrivateKey::from_str(leo_package::VALIDATOR_0_PRIVATE_KEY)?; let address = Address::try_from(&private_key)?; @@ -146,6 +149,6 @@ fn handle_debug(command: &LeoDebug, context: Context) -> Result<()> .map(|path_str| path_str.into()) .collect(); - leo_interpreter::interpret(&leo_paths, &aleo_paths, address, command.block_height) + leo_interpreter::interpret(&leo_paths, &aleo_paths, address, command.block_height, command.tui) } }