feat: with multiple args
Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
parent
1b9c9188d4
commit
e2feef1c27
@ -1,9 +1,12 @@
|
|||||||
use std::{path::PathBuf, str::FromStr};
|
use std::{path::PathBuf, str::FromStr};
|
||||||
|
|
||||||
use clap::{Arg, ArgMatches, Command};
|
use clap::{Arg, ArgGroup, ArgMatches, Command};
|
||||||
|
|
||||||
use crate::{cli::CuddleCli, model::CuddleVariable};
|
use crate::{cli::CuddleCli, model::CuddleVariable};
|
||||||
|
|
||||||
|
const DESTINATION: &'static str = "destination is the output path of the template once done, but default .tmpl is stripped and the normal file extension is used. this can be overwritten if a file path is entered instead. I.e. (/some/file/name.txt)";
|
||||||
|
const TEMPLATE_FILE: &'static str = "template-file is the input file path of the .tmpl file (or inferred) that you would like to render";
|
||||||
|
|
||||||
pub fn build_command(root_cmd: Command) -> Command {
|
pub fn build_command(root_cmd: Command) -> Command {
|
||||||
root_cmd.subcommand(
|
root_cmd.subcommand(
|
||||||
Command::new("render_template")
|
Command::new("render_template")
|
||||||
@ -14,19 +17,21 @@ pub fn build_command(root_cmd: Command) -> Command {
|
|||||||
.short('t')
|
.short('t')
|
||||||
.long("template-file")
|
.long("template-file")
|
||||||
.required(true)
|
.required(true)
|
||||||
.action(clap::ArgAction::Set).long_help("template-file is the input file path of the .tmpl file (or inferred) that you would like to render"),
|
.action(clap::ArgAction::Set)
|
||||||
|
.long_help(TEMPLATE_FILE),
|
||||||
Arg::new("destination")
|
Arg::new("destination")
|
||||||
.alias("dest")
|
.alias("dest")
|
||||||
.short('d')
|
.short('d')
|
||||||
.long("destination")
|
.long("destination")
|
||||||
.required(true)
|
.required(true)
|
||||||
.action(clap::ArgAction::Set)
|
.action(clap::ArgAction::Set)
|
||||||
.long_help("destination is the output path of the template once done, but default .tmpl is stripped and the normal file extension is used. this can be overwritten if a file path is entered instead. I.e. (/some/file/name.txt)"),
|
.long_help(DESTINATION),
|
||||||
Arg::new("extra-var")
|
Arg::new("extra-var")
|
||||||
.long("extra-var")
|
.long("extra-var")
|
||||||
.required(false)
|
.required(false)
|
||||||
.action(clap::ArgAction::Set),
|
.action(clap::ArgAction::Append),
|
||||||
]))
|
]),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct RenderTemplateCommand {
|
pub struct RenderTemplateCommand {
|
||||||
|
Loading…
Reference in New Issue
Block a user