make suggest setup help messages better

This commit is contained in:
Henry Boisdequin 2021-02-17 12:26:02 +05:30
parent 1279b3b923
commit e13f25cd66
1 changed files with 9 additions and 3 deletions

View File

@ -15,14 +15,17 @@ fn main() {
// check_version warnings are not printed during setup
let changelog_suggestion =
if matches!(config.cmd, Subcommand::Setup {..}) { None } else { check_version(&config) };
if matches!(config.cmd, Subcommand::Setup { .. }) { None } else { check_version(&config) };
// NOTE: Since `./configure` generates a `config.toml`, distro maintainers will see the
// changelog warning, not the `x.py setup` message.
let suggest_setup = !config.config.exists() && !matches!(config.cmd, Subcommand::Setup { .. });
if suggest_setup {
println!("warning: you have not made a `config.toml`");
println!("help: consider running `x.py setup` or copying `config.toml.example`");
println!(
"help: consider running `./x.py setup` or copying `config.toml.example` by running \
`cp config.toml.example config.toml`"
);
} else if let Some(suggestion) = &changelog_suggestion {
println!("{}", suggestion);
}
@ -31,7 +34,10 @@ fn main() {
if suggest_setup {
println!("warning: you have not made a `config.toml`");
println!("help: consider running `x.py setup` or copying `config.toml.example`");
println!(
"help: consider running `./x.py setup` or copying `config.toml.example` by running \
`cp config.toml.example config.toml`"
);
} else if let Some(suggestion) = &changelog_suggestion {
println!("{}", suggestion);
}