mirror of
https://github.com/MeexReay/bRAC.git
synced 2025-05-06 21:48:03 +03:00
stilno
This commit is contained in:
parent
7afca71b59
commit
8c9e6a6d2c
@ -135,9 +135,9 @@ pub fn print_console(ctx: Arc<Context>, messages: Vec<String>, input: &str) -> R
|
|||||||
s,
|
s,
|
||||||
" ".repeat(width - 1 - l),
|
" ".repeat(width - 1 - l),
|
||||||
if i == scroll_f {
|
if i == scroll_f {
|
||||||
"#"
|
"▐".bright_yellow()
|
||||||
} else {
|
} else {
|
||||||
"|"
|
"▕".yellow()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
@ -146,8 +146,9 @@ pub fn print_console(ctx: Arc<Context>, messages: Vec<String>, input: &str) -> R
|
|||||||
};
|
};
|
||||||
|
|
||||||
let text = format!(
|
let text = format!(
|
||||||
"{}\r\n> {}",
|
"{}\r\n{} {}",
|
||||||
formatted_messages.join("\r\n"),
|
formatted_messages.join("\r\n"),
|
||||||
|
">".bright_yellow(),
|
||||||
input
|
input
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
use std::sync::{atomic::AtomicUsize, Arc, RwLock};
|
use std::sync::{atomic::AtomicUsize, Arc, RwLock};
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
use std::{env, fs, path::{Path, PathBuf}, thread, time::Duration};
|
use std::{env, fs, path::{Path, PathBuf}, thread, time::Duration};
|
||||||
|
use colored::Colorize;
|
||||||
use homedir::my_home;
|
use homedir::my_home;
|
||||||
use rand::random;
|
use rand::random;
|
||||||
use serde_yml;
|
use serde_yml;
|
||||||
@ -36,7 +37,7 @@ fn default_host() -> String { "meex.lol:11234".to_string() }
|
|||||||
fn default_message_format() -> String { MESSAGE_FORMAT.to_string() }
|
fn default_message_format() -> String { MESSAGE_FORMAT.to_string() }
|
||||||
|
|
||||||
fn ask_usize(name: impl ToString, default: usize) -> usize {
|
fn ask_usize(name: impl ToString, default: usize) -> usize {
|
||||||
get_input(format!("{} (default: {}) > ", name.to_string(), default))
|
get_input(format!("{} (default: {}) > ", name.to_string(), default).bright_yellow())
|
||||||
.and_then(|o| o.parse().ok()).unwrap_or(default)
|
.and_then(|o| o.parse().ok()).unwrap_or(default)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,19 +47,19 @@ fn ask_string(name: impl ToString, default: impl ToString + Clone) -> String {
|
|||||||
|
|
||||||
fn ask_string_option(name: impl ToString, default: impl ToString) -> Option<String> {
|
fn ask_string_option(name: impl ToString, default: impl ToString) -> Option<String> {
|
||||||
let default = default.to_string();
|
let default = default.to_string();
|
||||||
get_input(format!("{} (default: {}) > ", name.to_string(), default))
|
get_input(format!("{} (default: {}) > ", name.to_string(), default).bright_yellow())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ask_bool(name: impl ToString, default: bool) -> bool {
|
fn ask_bool(name: impl ToString, default: bool) -> bool {
|
||||||
get_input(format!("{} (Y/N, default: {}) > ", name.to_string(), default))
|
get_input(format!("{} (Y/N, default: {}) > ", name.to_string(), if default { "Y" } else { "N" }).bright_yellow())
|
||||||
.map(|o| o.to_lowercase() != "n")
|
.map(|o| o.to_lowercase() != "n")
|
||||||
.unwrap_or(default)
|
.unwrap_or(default)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn configure(path: PathBuf) -> Config {
|
pub fn configure(path: PathBuf) -> Config {
|
||||||
println!("To configure the client, please answer a few questions. It won't take long.");
|
println!("{}", "To configure the client, please answer a few questions. It won't take long.".yellow());
|
||||||
println!("You can reconfigure client in any moment via `bRAC --configure`");
|
println!("{}", "You can reconfigure client in any moment via `bRAC --configure`".yellow());
|
||||||
println!("Config stores in path `{}`", path.to_string_lossy());
|
println!("{}", format!("Config stores in path `{}`", path.to_string_lossy()).yellow());
|
||||||
println!();
|
println!();
|
||||||
|
|
||||||
let host = ask_string("Host", default_host());
|
let host = ask_string("Host", default_host());
|
||||||
@ -82,7 +83,9 @@ pub fn configure(path: PathBuf) -> Config {
|
|||||||
let config_text = serde_yml::to_string(&config).expect("Config save error");
|
let config_text = serde_yml::to_string(&config).expect("Config save error");
|
||||||
fs::create_dir_all(&path.parent().expect("Config save error")).expect("Config save error");
|
fs::create_dir_all(&path.parent().expect("Config save error")).expect("Config save error");
|
||||||
fs::write(&path, config_text).expect("Config save error");
|
fs::write(&path, config_text).expect("Config save error");
|
||||||
println!("Config saved! You can edit it in the path got with `bRAC --config-path`");
|
|
||||||
|
println!();
|
||||||
|
println!("{}", "Config saved! You can reconfigure it in any moment via `bRAC --configure`".yellow());
|
||||||
|
|
||||||
config
|
config
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user