Skip to content

Commit a985fd2

Browse files
committed
Rename title -> proc_list_title
1 parent c9c9715 commit a985fd2

File tree

4 files changed

+19
-18
lines changed

4 files changed

+19
-18
lines changed

src/config.rs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ use crate::{
1212
yaml_val::{value_to_string, Val},
1313
};
1414

15-
const DEFAULT_PROCESSES_TITLE: &'static str = "Processes";
16-
1715
pub struct ConfigContext {
1816
pub path: PathBuf,
1917
}
@@ -25,7 +23,7 @@ pub struct Config {
2523
pub mouse_scroll_speed: usize,
2624
pub scrollback_len: usize,
2725
pub proc_list_width: usize,
28-
pub title: String,
26+
pub proc_list_title: String,
2927
}
3028

3129
impl Config {
@@ -65,13 +63,12 @@ impl Config {
6563
None
6664
};
6765

68-
let title = if let Some(title) = config.get(&Value::from("title")) {
69-
title.as_str()?.to_string()
70-
} else if let Some(title) = &settings.title {
71-
title.clone()
72-
} else {
73-
DEFAULT_PROCESSES_TITLE.to_string()
74-
};
66+
let proc_list_title =
67+
if let Some(title) = config.get(&Value::from("proc_list_title")) {
68+
title.as_str()?.to_string()
69+
} else {
70+
settings.proc_list_title.clone()
71+
};
7572

7673
let config = Config {
7774
procs,
@@ -80,7 +77,7 @@ impl Config {
8077
mouse_scroll_speed: settings.mouse_scroll_speed,
8178
scrollback_len: settings.scrollback_len,
8279
proc_list_width: settings.proc_list_width,
83-
title,
80+
proc_list_title,
8481
};
8582

8683
Ok(config)
@@ -94,7 +91,7 @@ impl Config {
9491
mouse_scroll_speed: settings.mouse_scroll_speed,
9592
scrollback_len: settings.scrollback_len,
9693
proc_list_width: settings.proc_list_width,
97-
title: DEFAULT_PROCESSES_TITLE.to_string(),
94+
proc_list_title: settings.proc_list_title.clone(),
9895
}
9996
}
10097
}

src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ async fn run_app() -> anyhow::Result<()> {
8989
.arg(arg!(-c --config [PATH] "Config path [default: mprocs.yaml]"))
9090
.arg(arg!(-s --server [PATH] "Remote control server address. Example: 127.0.0.1:4050."))
9191
.arg(arg!(--ctl [YAML] "Send yaml/json encoded command to running mprocs"))
92-
.arg(arg!(--title [TITLE] "Title for the processes pane"))
92+
.arg(arg!(--"proc-list-title" [TITLE] "Title for the processes pane"))
9393
.arg(arg!(--names [NAMES] "Names for processes provided by cli arguments. Separated by comma."))
9494
.arg(arg!(--npm "Run scripts from package.json. Scripts are not started by default."))
9595
.arg(arg!(--just "Run recipes from justfile. Recipes are not started by default. Requires just to be installed."))
@@ -132,8 +132,8 @@ async fn run_app() -> anyhow::Result<()> {
132132
return run_ctl(ctl_arg, &config).await;
133133
}
134134

135-
if let Some(title) = matches.get_one::<String>("title") {
136-
config.title = title.to_string();
135+
if let Some(title) = matches.get_one::<String>("proc-list-title") {
136+
config.proc_list_title = title.to_string();
137137
}
138138

139139
if let Some(cmds) = matches.get_many::<String>("COMMANDS") {

src/settings.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub struct Settings {
2121
pub mouse_scroll_speed: usize,
2222
pub scrollback_len: usize,
2323
pub proc_list_width: usize,
24-
pub title: Option<String>,
24+
pub proc_list_title: String,
2525
}
2626

2727
impl Default for Settings {
@@ -34,7 +34,7 @@ impl Default for Settings {
3434
mouse_scroll_speed: 5,
3535
scrollback_len: 1000,
3636
proc_list_width: 30,
37-
title: None,
37+
proc_list_title: "Processes".to_string(),
3838
};
3939
settings.add_defaults();
4040
settings
@@ -140,6 +140,10 @@ impl Settings {
140140
self.scrollback_len = scrollback.as_usize()?;
141141
}
142142

143+
if let Some(proc_list_title) = obj.get(&Value::from("proc_list_title")) {
144+
self.proc_list_title = proc_list_title.as_str()?.to_string().into();
145+
}
146+
143147
if let Some(proc_list_width) = obj.get(&Value::from("proc_list_width")) {
144148
self.proc_list_width = proc_list_width.as_usize()?;
145149
}

src/ui_procs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub fn render_procs(
4141

4242
let title = {
4343
let mut spans = vec![Span::styled(
44-
config.title.as_str(),
44+
config.proc_list_title.as_str(),
4545
theme.pane_title(active),
4646
)];
4747
if state.quitting {

0 commit comments

Comments
 (0)