diff options
| author | Daniel Jankowski <daniel.jankowski@rub.de> | 2024-10-24 18:26:25 +0200 |
|---|---|---|
| committer | Daniel Jankowski <daniel.jankowski@rub.de> | 2024-10-24 18:26:25 +0200 |
| commit | fec107e94b8c1924e4b0bd0c612687c64a7cc95f (patch) | |
| tree | 73f549332d6488006f6ba9f929d23c0eef8eb690 /src | |
| parent | feat: hide frames except on search (diff) | |
| download | sl0pstatus-fec107e94b8c1924e4b0bd0c612687c64a7cc95f.tar.gz sl0pstatus-fec107e94b8c1924e4b0bd0c612687c64a7cc95f.tar.xz sl0pstatus-fec107e94b8c1924e4b0bd0c612687c64a7cc95f.zip | |
feat: add error message for empty config
Diffstat (limited to 'src')
| -rw-r--r-- | src/bin/zjstatus.rs | 11 | ||||
| -rw-r--r-- | src/config.rs | 16 |
2 files changed, 18 insertions, 9 deletions
diff --git a/src/bin/zjstatus.rs b/src/bin/zjstatus.rs index 3ef57cc..4366db7 100644 --- a/src/bin/zjstatus.rs +++ b/src/bin/zjstatus.rs @@ -163,11 +163,12 @@ impl ZellijPlugin for State { self.state.cols = cols; tracing::debug!("{:?}", self.state.mode.session_name); - print!( - "{}", - self.module_config - .render_bar(self.state.clone(), self.widget_map.clone()) - ); + + let output = self + .module_config + .render_bar(self.state.clone(), self.widget_map.clone()); + + print!("{}", output); } } diff --git a/src/config.rs b/src/config.rs index c13328c..44f4313 100644 --- a/src/config.rs +++ b/src/config.rs @@ -309,6 +309,11 @@ impl ModuleConfig { state: ZellijState, widget_map: BTreeMap<String, Arc<dyn Widget>>, ) -> String { + if self.left_parts.is_empty() && self.center_parts.is_empty() && self.right_parts.is_empty() + { + return format!("No configuration found. See https://github.com/dj95/zjstatus/wiki/3-%E2%80%90-Configuration for more info"); + } + let output_left = self.left_parts.iter_mut().fold("".to_owned(), |acc, part| { format!( "{acc}{}", @@ -489,10 +494,13 @@ fn parts_from_config( config: &BTreeMap<String, String>, ) -> Vec<FormattedPart> { match format { - Some(format) => format - .split("#[") - .map(|s| FormattedPart::from_format_string(s, config)) - .collect(), + Some(format) => match format.is_empty() { + true => vec![], + false => format + .split("#[") + .map(|s| FormattedPart::from_format_string(s, config)) + .collect(), + }, None => vec![], } } |
