diff --git a/controller/src/command.rs b/controller/src/command.rs index 2828928..bf8a7e6 100644 --- a/controller/src/command.rs +++ b/controller/src/command.rs @@ -686,14 +686,6 @@ fn slatepack_recipient(dest: Option<&str>) -> Result, E .map_err(Error::from) } -fn print_contract_status(message: &str, as_json: bool) { - if as_json { - eprintln!("{}", message); - } else { - println!("{}", message); - } -} - pub fn print_slatepack( api: &mut Owner, keychain_mask: Option<&SecretKey>, @@ -1914,7 +1906,7 @@ where K: keychain::Keychain + 'static, { let recipient = slatepack_recipient(args.counterparty_addr.as_deref())?; - print_contract_status("Paste slatepack:", args.as_json); + display::print_status("Paste slatepack:", args.as_json); let slatepack_msg = read_slatepack(&mut io::stdin().lock()) .map_err(|e| libwallet::Error::GenericError(format!("Failed to read from stdin: {}", e)))?; let (slate, sender, _) = @@ -1940,7 +1932,7 @@ where if args.as_json { slate_out.print(true); } - print_contract_status("Transaction was broadcasted.", args.as_json); + display::print_status("Transaction was broadcasted.", args.as_json); } else { slate_out.print(args.as_json); } diff --git a/controller/src/display.rs b/controller/src/display.rs index 31b8649..d800bf7 100644 --- a/controller/src/display.rs +++ b/controller/src/display.rs @@ -26,6 +26,15 @@ use prettytable; use std::io::prelude::Write; use term; +/// Print a status message to stdout or stderr +pub fn print_status(message: &str, stderr: bool) { + if stderr { + eprintln!("{}", message); + } else { + println!("{}", message); + } +} + /// Display outputs in a pretty way pub fn outputs( account: &str, diff --git a/src/cmd/wallet.rs b/src/cmd/wallet.rs index ac801ec..b21a66b 100644 --- a/src/cmd/wallet.rs +++ b/src/cmd/wallet.rs @@ -15,6 +15,7 @@ use crate::cmd::wallet_args; use crate::config::GlobalWalletConfig; use clap::ArgMatches; +use grin_wallet_controller::display; use grin_wallet_libwallet::NodeClient; use semver::Version; use std::thread; @@ -22,14 +23,6 @@ use std::time::Duration; const MIN_COMPAT_NODE_VERSION: &str = "4.0.0-alpha.1"; -fn print_status(message: &str, stderr: bool) { - if stderr { - eprintln!("{}", message); - } else { - println!("{}", message); - } -} - pub fn wallet_command( wallet_args: &ArgMatches<'_>, config: GlobalWalletConfig, @@ -73,10 +66,10 @@ where thread::sleep(Duration::from_millis(100)); if let Err(e) = res { - print_status(&format!("Wallet command failed: {}", e), json_output); + display::print_status(&format!("Wallet command failed: {}", e), json_output); 1 } else { - print_status( + display::print_status( &format!( "Command '{}' completed successfully", wallet_args.subcommand().0