aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDaniel Jankowski <daniel.jankowski@rub.de>2025-09-07 16:45:04 +0200
committerDaniel Jankowski <daniel.jankowski@rub.de>2025-09-07 16:45:04 +0200
commite2ea91819408f0b0dd7ee15249341cace6eb09cc (patch)
treedf67a8fc94e734864cbed84e7f671b8e2c2c94b0 /src
parentchore(deps): bump actions/checkout from 4.2.2 to 5.0.0 (#176) (diff)
downloadsl0pstatus-e2ea91819408f0b0dd7ee15249341cace6eb09cc.tar.gz
sl0pstatus-e2ea91819408f0b0dd7ee15249341cace6eb09cc.tar.xz
sl0pstatus-e2ea91819408f0b0dd7ee15249341cace6eb09cc.zip
feat(command): hide on empty stdout
Diffstat (limited to 'src')
-rw-r--r--src/widgets/command.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/widgets/command.rs b/src/widgets/command.rs
index 5385dff..0a8d019 100644
--- a/src/widgets/command.rs
+++ b/src/widgets/command.rs
@@ -38,6 +38,7 @@ struct CommandConfig {
interval: i64,
render_mode: RenderMode,
click_action: String,
+ hide_on_empty_stdout: bool,
}
#[derive(Clone, Debug, Default)]
@@ -80,6 +81,10 @@ impl Widget for CommandWidget {
}
};
+ if command_config.hide_on_empty_stdout && command_result.stdout.is_empty() {
+ return "".to_owned();
+ }
+
let content = command_config
.format
.iter()
@@ -234,6 +239,7 @@ fn parse_config(zj_conf: &BTreeMap<String, String>) -> BTreeMap<String, CommandC
interval: 1,
render_mode: RenderMode::Static,
click_action: "".to_owned(),
+ hide_on_empty_stdout: false,
};
if let Some(existing_conf) = config.get(command_name.as_str()) {
@@ -288,6 +294,13 @@ fn parse_config(zj_conf: &BTreeMap<String, String>) -> BTreeMap<String, CommandC
};
}
+ if key.ends_with("hideonemptystdout") {
+ command_conf.hide_on_empty_stdout = match zj_conf.get(&key) {
+ Some(val) => val == "true",
+ None => false,
+ };
+ }
+
config.insert(command_name, command_conf);
}
@@ -489,6 +502,7 @@ mod test {
interval,
render_mode: RenderMode::Static,
click_action: "".to_owned(),
+ hide_on_empty_stdout: false,
},
"test",
state,