Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

other: flatten process config struct and clean up help text #1395

Merged
merged 6 commits into from
Jan 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions Cargo.lock

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

8 changes: 5 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ default = ["deploy"]
anyhow = "1.0.79"
backtrace = "0.3.69"
cfg-if = "1.0.0"
clap = { version = "4.4.16", features = ["default", "cargo", "wrap_help"] }
clap = { version = "4.4.18", features = ["default", "cargo", "wrap_help"] }
concat-string = "1.0.1"
crossterm = "0.27.0"
ctrlc = { version = "3.4.2", features = ["termination"] }
Expand All @@ -85,6 +85,7 @@ fern = { version = "0.6.2", optional = true }
hashbrown = "0.14.3"
humantime = "2.1.0"
indexmap = "2.1.0"
indoc = "2.0.4"
itertools = "0.12.0"
kstring = { version = "2.0.0", features = ["arc"] }
log = { version = "0.4.20", optional = true }
Expand Down Expand Up @@ -139,11 +140,12 @@ predicates = "3.0.4"
portable-pty = "0.8.1"

[build-dependencies]
clap = { version = "4.4.16", features = ["default", "cargo", "wrap_help"] }
clap_complete = "4.4.6"
clap = { version = "4.4.18", features = ["default", "cargo", "wrap_help"] }
clap_complete = "4.4.8"
clap_complete_fig = "4.4.2"
clap_complete_nushell = "4.4.2"
clap_mangen = "0.2.17"
indoc = "2.0.4"

[package.metadata.deb]
section = "utility"
Expand Down
32 changes: 32 additions & 0 deletions src/canvas/styling/colour_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,21 @@ The following are supported strings:
mod test {
use super::*;

#[test]
fn general_str_to_colour() {
assert_eq!(str_to_colour("red").unwrap(), Color::Red);
assert!(str_to_colour("r ed").is_err());

assert_eq!(str_to_colour("#ffffff").unwrap(), Color::Rgb(255, 255, 255));
assert!(str_to_colour("#fff fff").is_err());

assert_eq!(
str_to_colour("255, 255, 255").unwrap(),
Color::Rgb(255, 255, 255)
);
assert!(str_to_colour("255, 256, 255").is_err());
}

#[test]
fn invalid_colour_names() {
// Test invalid spacing in single word.
Expand Down Expand Up @@ -265,4 +280,21 @@ mod test {

assert!(convert_hex_to_color("#हिन्दी").is_err());
}

#[test]
fn test_rgb_colours() {
assert_eq!(
convert_rgb_to_color("0, 0, 0").unwrap(),
Color::Rgb(0, 0, 0)
);
assert_eq!(
convert_rgb_to_color("255, 255, 255").unwrap(),
Color::Rgb(255, 255, 255)
);
assert!(convert_rgb_to_color("255, 256, 255").is_err());
assert!(convert_rgb_to_color("256, 0, 256").is_err());
assert!(convert_rgb_to_color("1, -1, 1").is_err());
assert!(convert_rgb_to_color("1, -100000, 1").is_err());
assert!(convert_rgb_to_color("1, -100000, 100000").is_err());
}
}
7 changes: 1 addition & 6 deletions src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,7 @@ pub fn init_app(
let network_use_binary_prefix = is_flag_enabled!(network_use_binary_prefix, matches, config);

let proc_columns: Option<IndexSet<ProcWidgetColumn>> = {
let columns = config
.processes
.as_ref()
.and_then(|cfg| cfg.columns.clone());
let columns = config.processes.as_ref().map(|cfg| cfg.columns.clone());

match columns {
Some(columns) => {
Expand Down Expand Up @@ -410,8 +407,6 @@ pub fn get_widget_layout(
// Confirm that we have at least ONE widget left - if not, error out!
if iter_id > 0 {
ret_bottom_layout.get_movement_mappings();
// debug!("Bottom layout: {ret_bottom_layout:#?}");

ret_bottom_layout
} else {
return Err(BottomError::ConfigError(
Expand Down
Loading