Skip to content

Commit e3635e1

Browse files
FroVolodFroVolodfrol
authored
feat: Updated user interface for interactive mode (#524)
The user interface for interactive mode has been updated. It is now much more readable than before. Before update: https://github.com/user-attachments/assets/89c160ae-d698-46da-94bd-853c42907a0d After update: https://github.com/user-attachments/assets/340d758d-7b03-4dc6-b852-114d1cdc0d9c --------- Co-authored-by: FroVolod <frol_off@meta.ua> Co-authored-by: Vlad Frolov <frolvlad@gmail.com>
1 parent 829600a commit e3635e1

File tree

24 files changed

+140
-127
lines changed

24 files changed

+140
-127
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ name: Run Tests
22
on:
33
pull_request:
44
push:
5+
branches:
6+
- main
57

68
jobs:
79
tests:

Cargo.lock

Lines changed: 43 additions & 64 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ path = "src/main.rs"
2424

2525
[dependencies]
2626
clap = { version = "4.0.18", features = ["derive"] }
27-
inquire = "0.7"
27+
inquire-clack = "0.1.0"
2828
strum = { version = "0.24", features = ["derive"] }
2929
strum_macros = "0.24"
3030
smart-default = "0.7.1"

src/commands/account/add_key/access_key_type/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ impl FunctionCallType {
118118
No,
119119
}
120120

121-
eprintln!();
122121
let select_choose_input = Select::new(
123122
"Would you like the access key to be valid exclusively for calling specific functions on the contract?",
124123
vec![ConfirmOptions::Yes, ConfirmOptions::No],

src/commands/account/create_account/create_implicit_account/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ impl SaveToFolder {
6464
fn input_folder_path(
6565
context: &SaveImplicitAccountContext,
6666
) -> color_eyre::eyre::Result<Option<crate::types::path_buf::PathBuf>> {
67-
eprintln!();
6867
Ok(Some(
6968
CustomType::new("Where to save the implicit account file?")
7069
.with_starting_input(&format!(

src/commands/account/create_account/fund_myself_create_account/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ impl NewAccount {
131131
fn input_initial_balance(
132132
_context: &crate::GlobalContext,
133133
) -> color_eyre::eyre::Result<Option<crate::types::near_token::NearToken>> {
134-
eprintln!();
135134
Ok(Some(
136135
CustomType::new("Enter the amount of the NEAR tokens you want to fund the new account with (example: 10NEAR or 0.5near or 10000yoctonear):")
137136
.with_starting_input("0.1 NEAR")

src/commands/account/delete_account/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ impl BeneficiaryAccount {
146146
No,
147147
}
148148
let select_choose_input =
149-
Select::new("\nDo you want to check the existence of the specified account so that you don't lose tokens?",
149+
Select::new("Do you want to check the existence of the specified account so that you don't lose tokens?",
150150
vec![ConfirmOptions::Yes{account_id: beneficiary_account_id.clone()}, ConfirmOptions::No],
151151
)
152152
.prompt()?;

src/commands/account/delete_key/public_keys_to_delete.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use color_eyre::owo_colors::OwoColorize;
2+
use inquire::ui::{Color, RenderConfig, Styled};
23
use inquire::{formatter::MultiOptionFormatter, CustomType, MultiSelect};
34

45
use crate::common::JsonRpcClientExt;
@@ -137,13 +138,14 @@ impl PublicKeyList {
137138
.iter()
138139
.map(|list_option| list_option.value.to_string())
139140
.collect::<Vec<_>>();
140-
format!("\n{}", public_key_list.join("\n"))
141+
public_key_list.join("\n").to_string()
141142
};
142143

143144
let selected_public_keys = MultiSelect::new(
144145
"Select the public keys you want to delete:",
145146
access_key_list,
146147
)
148+
.with_render_config(get_multi_select_render_config())
147149
.with_formatter(formatter)
148150
.with_validator(
149151
|list: &[inquire::list_option::ListOption<&AccessKeyInfo>]| {
@@ -222,3 +224,12 @@ impl std::fmt::Display for AccessKeyInfo {
222224
}
223225
}
224226
}
227+
228+
fn get_multi_select_render_config() -> RenderConfig<'static> {
229+
let mut render_config = crate::get_global_render_config();
230+
render_config.highlighted_option_prefix = Styled::new(">").with_fg(Color::DarkGreen);
231+
render_config.unhighlighted_option_prefix = Styled::new(" ").with_fg(Color::DarkGrey);
232+
render_config.scroll_up_prefix = Styled::new("↑").with_fg(Color::DarkGrey);
233+
render_config.scroll_down_prefix = Styled::new("↓").with_fg(Color::DarkGrey);
234+
render_config
235+
}

0 commit comments

Comments
 (0)