feat: with variables
Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
parent
2241941f0e
commit
04e8baeefc
@ -22,7 +22,8 @@ pub fn build_command(root_cmd: Command, _cli: CuddleCli) -> Command {
|
||||
.about("init bootstraps a repository from a template")
|
||||
.arg(repo_url)
|
||||
.arg(clap::Arg::new("name"))
|
||||
.arg(clap::Arg::new("path"));
|
||||
.arg(clap::Arg::new("path"))
|
||||
.arg(clap::Arg::new("value").short('v').long("value"));
|
||||
|
||||
root_cmd.subcommand(execute_cmd)
|
||||
}
|
||||
@ -31,6 +32,10 @@ pub fn execute_init(exe_submatch: &ArgMatches, _cli: CuddleCli) -> anyhow::Resul
|
||||
let repo = exe_submatch.get_one::<String>("repo").unwrap();
|
||||
let name = exe_submatch.get_one::<String>("name");
|
||||
let path = exe_submatch.get_one::<String>("path");
|
||||
let values = exe_submatch
|
||||
.get_many::<String>("value")
|
||||
.unwrap_or_default()
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
tracing::info!("Downloading: {}", repo);
|
||||
|
||||
@ -134,7 +139,15 @@ pub fn execute_init(exe_submatch: &ArgMatches, _cli: CuddleCli) -> anyhow::Resul
|
||||
|
||||
{
|
||||
if let Some(ref mut prompt) = template.prompt {
|
||||
for (name, prompt) in prompt {
|
||||
'prompt: for (name, prompt) in prompt {
|
||||
for value in &values {
|
||||
if let Some((value_name, value_content)) = value.split_once("=") {
|
||||
if value_name == name {
|
||||
prompt.value = value_content.to_string();
|
||||
continue 'prompt;
|
||||
}
|
||||
}
|
||||
}
|
||||
let value = inquire::Text::new(&name)
|
||||
.with_help_message(&prompt.description)
|
||||
.prompt()?;
|
||||
|
Loading…
Reference in New Issue
Block a user