-
Here is my config, which doesn't work. Two issues:
[template]
cargo_generate_version = ">=0.10.0"
[placeholders.gh-username]
type = "string"
prompt = "GitHub username (or organization)?"
# The username cannot end with a hyphen, too, but
# this requirement is not captured by the regex at the moment.
regex = "^[A-Za-z0-9][A-Za-z0-9-]{0,38}$"
[placeholders.project-description]
type = "string"
prompt = "Project description?"
[placeholders.cmake-min-version]
type = "string"
prompt = "CMake minimum version?"
regex = "^[0-9]+(\\.[0-9]+){0,2}$"
[placeholders.cxx-standard]
type = "string"
prompt = "Cxx standard version?"
regex = "^[0-9]+$"
[placeholders.project-type]
type = "string"
prompt = "Which cxx project type?"
choices = [
"bin",
"lib"
]
default = "bin"
[conditional.'project-type == "bin"']
ignore = ["src/library.h", "src/library.cpp"]
[conditional.'project-type == "lib"'.placeholders.lib-type]
ignore = ["src/main.cpp"]
type = "string"
prompt = "Which lib type?"
choices = ["static", "shared"]
default = "shared"
cmake_minimum_required(VERSION {{cmake-min-version}})
project({{project-name}})
set(CMAKE_CXX_STANDARD {{cxx-standard}})
{% if project-type == "bin" -%}
add_executable({{project-name}} src/main.cpp)
{%- else -%}
{%- if lib-type == "static" -%}
# static
add_library({{project-name}} src/library.cpp)
{%- else -%}
# shared
add_library({{project-name}} SHARED src/library.cpp)
{%- endif %}
{%- endif %} |
Beta Was this translation helpful? Give feedback.
Answered by
pplmx
Sep 5, 2022
Replies: 1 comment
-
After renaming all variables: replace - with _ FYI. Here is my final config.[template]
cargo_generate_version = ">=0.10.0"
[placeholders.gh_uname]
type = "string"
prompt = "GitHub username (or organization)?"
# The username cannot end with a hyphen, too, but
# this requirement is not captured by the regex at the moment.
regex = "^[A-Za-z0-9][A-Za-z0-9-]{0,38}$"
[placeholders.proj_description]
type = "string"
prompt = "Project description?"
[placeholders.cmake_min_version]
type = "string"
prompt = "CMake minimum version?"
regex = "^[0-9]+(\\.[0-9]+){0,2}$"
[placeholders.cxx_standard_version]
type = "string"
prompt = "Cxx standard version?"
regex = "^[0-9]+$"
[placeholders.proj_type]
type = "string"
prompt = "Which cxx project type?"
choices = ["bin", "lib"]
default = "bin"
[conditional.'proj_type == "lib"'.placeholders.lib_type]
type = "string"
prompt = "Which lib type?"
choices = ["static", "shared"]
default = "shared"
[conditional.'proj_type == "bin"']
ignore = ["src/library.h", "src/library.cpp"]
[conditional.'proj_type == "lib"']
ignore = ["src/main.cpp"]
|
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
pplmx
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
After renaming all variables: replace - with _
It works fine.
FYI. Here is my final config.