ui: define default ui.quiet and .progress-indicator in config/misc.toml

This commit is contained in:
Yuya Nishihara 2024-12-01 14:21:01 +09:00
parent 3a38d7a670
commit a7339244b8
3 changed files with 9 additions and 4 deletions

View file

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

View file

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

View file

@ -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(())
}