Skip to content

Commit

Permalink
Merge pull request #163 from Concordium/tag-templating
Browse files Browse the repository at this point in the history
Added option for tags to cargo init
  • Loading branch information
abizjak authored Apr 7, 2024
2 parents 216f1ef + 26f2445 commit 97ee2cb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 2 additions & 0 deletions cargo-concordium/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased changes

- Added a `tag` option to `cargo concordium init`

## 3.3.0

- Bump minimum Rust version to 1.73.
Expand Down
4 changes: 3 additions & 1 deletion cargo-concordium/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@ pub fn build_contract_schema<A>(
/// Create a new Concordium smart contract project from a template, or there
/// are runtime exceptions that are not expected then this function returns
/// `Err(...)`.
pub fn init_concordium_project(path: impl AsRef<Path>) -> anyhow::Result<()> {
pub fn init_concordium_project(path: impl AsRef<Path>, tag: &str) -> anyhow::Result<()> {
let path = path.as_ref();

let absolute_path = if path.is_absolute() {
Expand All @@ -802,6 +802,8 @@ pub fn init_concordium_project(path: impl AsRef<Path>) -> anyhow::Result<()> {
"--git",
"https://github.com/Concordium/concordium-rust-smart-contracts",
"templates",
"--tag",
tag,
])
.args(["--destination", absolute_path.to_str().unwrap()])
.stdout(Stdio::inherit())
Expand Down
12 changes: 10 additions & 2 deletions cargo-concordium/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,14 @@ This command also builds a deployable Wasm module for integration testing, and i
help = "The path where the project should be created."
)]
path: PathBuf,
#[structopt(
name = "tag",
long = "tag",
short = "t",
default_value = "releases/templates/latest",
help = "The release tag of the template to use."
)]
tag: String,
},
#[structopt(
name = "schema-json",
Expand Down Expand Up @@ -676,8 +684,8 @@ pub fn main() -> anyhow::Result<()> {

eprintln!("{}", Color::Green.bold().paint("All tests passed"));
}
Command::Init { path } => {
init_concordium_project(path)
Command::Init { path, tag } => {
init_concordium_project(path, &tag)
.context("Could not create a new Concordium smart contract project.")?;
}
Command::SchemaJSON {
Expand Down

0 comments on commit 97ee2cb

Please sign in to comment.