Skip to content

Commit

Permalink
ui: define default ui.quiet and .progress-indicator in config/misc.toml
Browse files Browse the repository at this point in the history
  • Loading branch information
yuja committed Dec 7, 2024
1 parent 719ec96 commit f53602d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

### Breaking changes

* The following configuration variables are now parsed strictly:
`ui.progress-indicator`, `ui.quiet`

### Deprecations

### New features
Expand Down
2 changes: 2 additions & 0 deletions cli/src/config/misc.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ diff-instructions = true
graph.style = "curved"
paginate = "auto"
pager = { command = ["less", "-FRX"], env = { LESSCHARSET = "utf-8" } }
progress-indicator = true
quiet = false
log-word-wrap = false
log-synthetic-elided-nodes = true
conflict-marker-style = "diff"
Expand Down
8 changes: 4 additions & 4 deletions cli/src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,20 +339,20 @@ impl Ui {
pub fn with_config(config: &StackedConfig) -> Result<Ui, CommandError> {
let formatter_factory = prepare_formatter_factory(config, &io::stdout())?;
Ok(Ui {
quiet: config.get("ui.quiet").unwrap_or_default(),
quiet: config.get("ui.quiet")?,
formatter_factory,
pager_cmd: config.get("ui.pager")?,
paginate: config.get("ui.paginate")?,
progress_indicator: config.get("ui.progress-indicator").unwrap_or(true),
progress_indicator: config.get("ui.progress-indicator")?,
output: UiOutput::new_terminal(),
})
}

pub fn reset(&mut self, config: &StackedConfig) -> Result<(), CommandError> {
self.quiet = config.get("ui.quiet").unwrap_or_default();
self.quiet = config.get("ui.quiet")?;
self.paginate = config.get("ui.paginate")?;
self.pager_cmd = config.get("ui.pager")?;
self.progress_indicator = config.get("ui.progress-indicator").unwrap_or(true);
self.progress_indicator = config.get("ui.progress-indicator")?;
self.formatter_factory = prepare_formatter_factory(config, &io::stdout())?;
Ok(())
}
Expand Down

0 comments on commit f53602d

Please sign in to comment.