-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cli): support '--no-client' and '--no-gtest' flags in 'cargo-sai…
…ls' template (#487)
- Loading branch information
1 parent
dc99b52
commit 36cf95d
Showing
5 changed files
with
70 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
[template] | ||
sub_templates = ["program", "program-with-client", "program-with-gtest"] | ||
sub_templates = ["program"] | ||
|
||
# [placeholders] | ||
# program-name = { prompt = "Program name in PascalCase", type = "string" } | ||
# program-name-snake = { prompt = "Program name in snake-case", type = "string" } | ||
[placeholders] | ||
with-client = { type = "bool", prompt = "Add client project?" } | ||
with-gtest = { type = "bool", prompt = "Add gtest project?" } | ||
|
||
[hooks] | ||
pre = ["../set-vars.rhai"] | ||
pre = ["../pre-hook.rhai"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
let sails_cli_min_version_str = "0.4.0"; | ||
let sails_cli_min_version = parse_sem_ver(sails_cli_min_version_str); | ||
|
||
let sails_cli_version_str = if variable::is_set("sails-cli-version") { | ||
variable::get("sails-cli-version") | ||
} else { | ||
"0" | ||
}; | ||
let sails_cli_version = parse_sem_ver(sails_cli_version_str); | ||
|
||
if sails_cli_version[0] < sails_cli_min_version[0] | ||
|| sails_cli_version[1] < sails_cli_min_version[1] | ||
|| sails_cli_version[2] < sails_cli_min_version[2] { | ||
abort("Sails CLI version '" + sails_cli_version_str + "' is not supported. Please upgrade to '" + sails_cli_min_version_str + "' or higher"); | ||
} | ||
|
||
fn parse_sem_ver(version) { | ||
let dot_idx = 0; | ||
let dot_idx_next = index_of(version, ".", dot_idx); | ||
let major = if dot_idx_next == -1 { | ||
version.sub_string(dot_idx) | ||
} else { | ||
version.sub_string(dot_idx..dot_idx_next) | ||
}; | ||
major = parse_int(major); | ||
|
||
dot_idx = dot_idx_next + 1; | ||
dot_idx_next = index_of(version, ".", dot_idx); | ||
let minor = if dot_idx == 0 { | ||
"0" | ||
} else if dot_idx_next == -1 { | ||
version.sub_string(dot_idx) | ||
} else { | ||
version.sub_string(dot_idx..dot_idx_next) | ||
}; | ||
minor = parse_int(minor); | ||
|
||
dot_idx = dot_idx_next + 1; | ||
dot_idx_next = index_of(version, ".", dot_idx); | ||
let patch = if dot_idx == 0 { | ||
"0" | ||
} else if dot_idx_next == -1 { | ||
version.sub_string(dot_idx) | ||
} else { | ||
abort("Version '" + version + "' does not conform to semantic versioning"); | ||
}; | ||
patch = parse_int(patch); | ||
|
||
[major, minor, patch] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import "../set-vars"; | ||
import "../check-version"; | ||
|
||
let with_client = variable::get("with-client"); | ||
let with_gtest = variable::get("with-gtest"); | ||
if !with_client { | ||
file::delete("client") | ||
} | ||
if !with_client || !with_gtest { | ||
file::delete("tests") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters