feat(print-config): list expanded $all variable (#2932)

* feat(print-config): list expanded `$all` variable

* handle $custom

* improve comment
This commit is contained in:
David Knaack 2021-09-01 20:32:32 +02:00 committed by GitHub
parent 85f7a4be39
commit c6e5e6fbed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,6 +5,7 @@ use std::process;
use crate::config::RootModuleConfig;
use crate::config::StarshipConfig;
use crate::configs::PROMPT_ORDER;
use crate::utils;
use std::fs::File;
use std::io::Write;
@ -70,7 +71,26 @@ pub fn print_configuration(use_default: bool) {
let string_config = toml::to_string_pretty(&config).unwrap();
println!("# Warning: This config does not include keys that have an unset value");
println!("# Warning: This config does not include keys that have an unset value\n");
println!(
"# $all is shorthand for {}",
PROMPT_ORDER
.iter()
.map(|module_name| format!("${}", module_name))
.collect::<String>()
);
// Unwrapping is fine because config is based on FullConfig
let custom_modules = config.get("custom").unwrap().as_table().unwrap();
if !use_default && !custom_modules.is_empty() {
println!(
"# $custom (excluding any modules already listed in `format`) is shorthand for {}",
custom_modules
.keys()
.map(|module_name| format!("${{custom.{}}}", module_name))
.collect::<String>()
);
}
println!("{}", string_config);
}