Merge pull request #89 from korrat/add-compact-output

Add compact output option. Fixes #88.
This commit is contained in:
Danilo Bargen 2019-10-04 00:52:43 +02:00 committed by GitHub
commit 07e2ee86f5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 3 deletions

View file

@ -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

View file

@ -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<RawConfig> for Config {
example_variable: raw_config.style.example_variable.into(),
},
display: DisplayConfig {
compact: raw_config.display.compact,
use_pager: raw_config.display.use_pager,
},
}

View file

@ -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");

View file

@ -18,3 +18,4 @@ bold = false
[display]
use_pager = false
compact = false