Skip to content

Commit

Permalink
Merge branch 'development' into issue-4514-send_transaction_specific_…
Browse files Browse the repository at this point in the history
…utxos
  • Loading branch information
agubarev committed Sep 5, 2022
2 parents 3bb4e18 + 5cbf9aa commit c671b29
Show file tree
Hide file tree
Showing 76 changed files with 1,268 additions and 1,525 deletions.
115 changes: 49 additions & 66 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 2 additions & 19 deletions applications/tari_base_node/src/commands/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@
use std::io::stdout;

use chrono::{Datelike, Utc};
use crossterm::{
execute,
terminal::{SetSize, SetTitle},
};
use crossterm::{execute, terminal::SetTitle};
use tari_app_utilities::consts;

/// returns the top or bottom box line of the specified length
Expand Down Expand Up @@ -106,17 +103,8 @@ fn multiline_find_display_length(lines: &str) -> usize {
result
}

/// Try to resize terminal to make sure the width is enough.
/// In case of error, just simply print out the error.
#[allow(clippy::cast_possible_truncation)]
fn resize_terminal_to_fit_the_box(width: usize, height: usize) {
if let Err(e) = execute!(stdout(), SetSize(width as u16, height as u16)) {
println!("Can't resize terminal to fit the box. Error: {}", e)
}
}

/// Prints a pretty banner on the console as well as the list of available commands
pub fn print_banner(commands: Vec<String>, chunk_size: usize, resize_terminal: bool) {
pub fn print_banner(commands: Vec<String>, chunk_size: usize) {
let terminal_title = format!("Tari Base Node - Version {}", consts::APP_VERSION);
if let Err(e) = execute!(stdout(), SetTitle(terminal_title.as_str())) {
println!("Error setting terminal title. {}", e)
Expand Down Expand Up @@ -191,13 +179,8 @@ pub fn print_banner(commands: Vec<String>, chunk_size: usize, resize_terminal: b
let rows = box_tabular_data_rows(command_data, row_cell_size, target_line_length, 10);
// There are 24 fixed rows besides the possible changed "Commands" rows
// and plus 2 more blank rows for better layout.
let height_to_resize = &rows.len() + 24 + 2;
for row in rows {
println!("{}", row);
}
println!("{}", box_line(target_line_length, false));

if resize_terminal {
resize_terminal_to_fit_the_box(target_line_length, height_to_resize);
}
}
4 changes: 2 additions & 2 deletions applications/tari_base_node/src/commands/cli_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ impl CliLoop {
///
/// ## Returns
/// Doesn't return anything
pub async fn cli_loop(mut self, resize_terminal_on_startup: bool) {
cli::print_banner(self.commands.clone(), 3, resize_terminal_on_startup);
pub async fn cli_loop(mut self) {
cli::print_banner(self.commands.clone(), 3);

if self.non_interactive {
self.watch_loop_non_interactive().await;
Expand Down
Loading

0 comments on commit c671b29

Please sign in to comment.