From a9f2a4c1328cbba6b4f606afb4437443ab3bde41 Mon Sep 17 00:00:00 2001 From: Korrat Date: Thu, 3 Oct 2019 11:43:24 +0200 Subject: [PATCH 1/3] Add config field for compact output --- src/config.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/config.rs b/src/config.rs index dcd68cb..42d5311 100644 --- a/src/config.rs +++ b/src/config.rs @@ -110,6 +110,8 @@ struct RawStyleConfig { #[derive(Debug, Default, Serialize, Deserialize, PartialEq, Eq)] struct RawDisplayConfig { + #[serde(default)] + pub compact: bool, #[serde(default)] pub use_pager: bool, } @@ -149,6 +151,7 @@ pub struct StyleConfig { #[derive(Copy, Clone, Debug, PartialEq)] pub struct DisplayConfig { + pub compact: bool, pub use_pager: bool, } @@ -169,6 +172,7 @@ impl From for Config { example_variable: raw_config.style.example_variable.into(), }, display: DisplayConfig { + compact: raw_config.display.compact, use_pager: raw_config.display.use_pager, }, } From 7f8cbb01e5b133ededf381fde12ed914069bd226 Mon Sep 17 00:00:00 2001 From: Korrat Date: Thu, 3 Oct 2019 11:55:07 +0200 Subject: [PATCH 2/3] Suppress empty lines for compact output --- src/formatter.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/formatter.rs b/src/formatter.rs index 488f8ed..40ec5bf 100644 --- a/src/formatter.rs +++ b/src/formatter.rs @@ -57,7 +57,11 @@ where let mut command = String::new(); while let Some(token) = tokenizer.next_token() { match token { - LineType::Empty => println!(), + LineType::Empty => { + if !config.display.compact { + println!() + } + } LineType::Title(title) => { debug!("Ignoring title"); From 6810693655f2467024781a976b49628447675243 Mon Sep 17 00:00:00 2001 From: Danilo Bargen Date: Thu, 3 Oct 2019 23:56:07 +0200 Subject: [PATCH 3/3] Document compact output option in README --- README.md | 15 +++++++++++++-- tests/config.toml | 1 + 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b0e7a42..a32abe3 100644 --- a/README.md +++ b/README.md @@ -180,8 +180,11 @@ Example customization: ### Display -Using `display` config you can customize whether the pager should be use by -default or not (default `false`). +In the `display` section you can configure the output format. + +#### `use_pager` + +Specifies whether the pager should be used by default or not (default `false`). [display] use_pager = true @@ -189,6 +192,14 @@ default or not (default `false`). When enabled, `less -R` is used as pager. To override the pager command used, set the `PAGER` environment variable. +#### `compact` + +Set this to enforce more compact output, where empty lines are stripped out +(default `false`). + + [display] + compact = true + ## Autocompletion diff --git a/tests/config.toml b/tests/config.toml index 5319e7a..c3a9cd6 100644 --- a/tests/config.toml +++ b/tests/config.toml @@ -18,3 +18,4 @@ bold = false [display] use_pager = false +compact = false