diff --git a/forc/src/cli/commands/template.rs b/forc/src/cli/commands/template.rs index 10a9d905639..7f9db2c0bd5 100644 --- a/forc/src/cli/commands/template.rs +++ b/forc/src/cli/commands/template.rs @@ -22,6 +22,14 @@ pub struct Command { /// The name of the project that will be created pub project_name: String, + + /// A git tag to use for the template, e.g. `v0.1.0`. + #[clap(long)] + pub tag: Option, + + /// A specific git revision (commit hash) to use for the template. + #[clap(long)] + pub rev: Option, } pub(crate) fn exec(command: Command) -> ForcResult<()> { diff --git a/forc/src/ops/forc_template.rs b/forc/src/ops/forc_template.rs index 0304a9d298a..551bc2f07b4 100644 --- a/forc/src/ops/forc_template.rs +++ b/forc/src/ops/forc_template.rs @@ -21,9 +21,16 @@ pub fn init(command: TemplateCommand) -> Result<()> { .clone() .unwrap_or_else(|| format!("{}-template-source", command.project_name)); + let reference = if let Some(rev) = &command.rev { + source::git::Reference::Rev(rev.clone()) + } else if let Some(tag) = &command.tag { + source::git::Reference::Tag(tag.clone()) + } else { + source::git::Reference::DefaultBranch + }; let source = source::git::Source { repo: Url::from_str(&command.url)?, - reference: source::git::Reference::DefaultBranch, + reference, }; let current_dir = &env::current_dir()?;