Provide an environment variable for controlling background colour

Fixes #55
html_output
Wilfred Hughes 2022-01-29 16:07:31 +07:00
parent c38b072fd2
commit 36c4520025
2 changed files with 11 additions and 4 deletions

@ -24,7 +24,7 @@ Added a `--color` option which allows explicitly enabling/disabling
colour output.
Added a `--background` option which controls whether difftastic uses
bright or dark colours.
bright or dark colours. This can also be controlled by `DFT_BACKGROUND`.
## 0.17 (released 25 January 2022)

@ -149,9 +149,8 @@ fn app() -> clap::App<'static> {
)
.arg(
Arg::new("background").long("background")
.default_value("dark")
.possible_values(["dark", "light"])
.help("Set the background color. Difftastic will prefer brighter colours on dark backgrounds.")
.help("Set the background color. Overrides $DFT_BACKGROUND if present. Difftastic will prefer brighter colours on dark backgrounds.")
)
.arg(
Arg::new("paths")
@ -244,8 +243,16 @@ fn parse_args() -> Mode {
} else {
BackgroundColor::Dark
}
} else {
if let Ok(background) = env::var("DFT_BACKGROUND") {
if background == "light" {
BackgroundColor::Light
} else {
BackgroundColor::Dark
}
} else {
BackgroundColor::Dark
}
};
Mode::Diff {