vala-lang / valdo

Create new Vala projects from templates
GNU Lesser General Public License v2.1
52 stars 14 forks source link

only test regex pattern if user input not empty #1

Closed aeldemery closed 3 years ago

aeldemery commented 3 years ago

If the user press enter without input, the regex test fails, so test it only if non default value.

Prince781 commented 3 years ago

While it's a little awkward, I think we want the regex to match the default value. If it doesn't, then the template needs to be corrected.

aeldemery commented 3 years ago

Ok, now I understand what the problem is. If I put the default value as one of the project variables, it may fail as it's not get substituted. example: If I made a variable ${APP_REAL_NAME} and put the default as ${PROJECT_NAME} it fails because it test the regex against ${PROJECT_NAME} not its value. It's also not very convenient as it doesn't display the substituted value to the user. Any idea how to solve this?

Prince781 commented 3 years ago

@aeldemery usually you'd want to reference a variable to copy it in some modified form. Therefore, your default should be of the form /${OTHER_VARIABLE}/<non-empty match pattern>/<possibly empty replacement pattern>/. If you're defining a variable to be exactly another variable, then you just use that variable instead in your template files, right?

Prince781 commented 3 years ago

@aeldemery I pushed some fixes to substitution recently. Maybe it helps with your problem. Let me know how I can help you with making a template.