add config keys (#31)

Reviewed-on: http://192.168.1.227:3000/sfrembling/pallet/pulls/31
Co-authored-by: Shea Frembling <sfrembling@gmail.com>
Co-committed-by: Shea Frembling <sfrembling@gmail.com>
This commit was merged in pull request #31.
This commit is contained in:
2026-03-23 20:49:32 -06:00
committed by sfrembling
parent 130525a868
commit 9cfcd14e0a
2 changed files with 51 additions and 0 deletions

View File

@@ -95,6 +95,8 @@ enum UtilSubcommand {
/// The build mode to generate for /// The build mode to generate for
mode: Option<String>, mode: Option<String>,
}, },
/// Generate the config keys for Pallet.toml
GenConfigKeys,
} }
#[derive(Clone, clap::ValueEnum)] #[derive(Clone, clap::ValueEnum)]
@@ -193,6 +195,15 @@ impl App {
std::process::exit(1); std::process::exit(1);
} }
} }
UtilSubcommand::GenConfigKeys => {
println!(
"{} a property with a '?' indicates that the property is optional",
"Hint".yellow().bold()
);
for (id, desc, dt) in crate::config::Config::get_config_syntax() {
println!(" - {} ({}): {desc}", id.green().bold(), dt.blue().bold());
}
}
}, },
Subcommand::List => { Subcommand::List => {
if let Err(e) = list() { if let Err(e) = list() {

View File

@@ -35,6 +35,46 @@ impl Config {
self.build.iter().find(|bc| bc.name == self.default_build) self.build.iter().find(|bc| bc.name == self.default_build)
} }
} }
pub fn get_config_syntax() -> Vec<(String, String, String)> {
vec![
(
"compiler?",
"the compiler used by Pallet (defeault=gcc)",
"string",
),
("name", "the name of your application", "string"),
(
"default_build",
"the name of the build to use by default when running or building",
"string",
),
(
"description?",
"a brief description of your application",
"string",
),
("version?", "the version of your application", "string"),
(
"authors?",
"the author or authors of your application",
"string[]",
),
(
"build",
"a build config that can be used when compiling",
"{name: string, args: string[]}[]",
),
(
"dependencies",
"libraries (such as zlib) used by your application that require pkg-config to be compiled correclty",
"string[]"
)
]
.into_iter()
.map(|(a, b, c)| (a.to_owned(), b.to_owned(), c.to_owned()))
.collect()
}
} }
#[derive(serde::Deserialize, serde::Serialize)] #[derive(serde::Deserialize, serde::Serialize)]