vala-lang / valdo

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

allow templating directory names #6

Closed aeldemery closed 3 years ago

aeldemery commented 3 years ago

with this PR, one would be able to use variables inside project directory structures.

Prince781 commented 3 years ago

Using $ in folder names is a bit iffy, especially on Unix-like operating systems.

aeldemery commented 3 years ago

But I have tested it $ and it's an acceptable char in folder names.

Actually I just remembered I should refactor the code to allow also files not only folders. So probably I would visit the code again as soon as I get some time.

aeldemery commented 3 years ago

according to various internet sources both the characters $ and { /} are allowed inside path and filenames in windows and linux.

Moreover it's been used with other templating engines like jinja2 and tera.

My goal was to produce files like this for example:

com.example.proj-name.icon
com.example.proj-name.desktop.in

If you have a veto against using templating in files/folder-names to keep valdo simple, please let me know so I would abort my efforts.

I would also suggest to change templated files extension form in to something else to avoid conflicts with meson, for example .template or .tmpl .

Prince781 commented 3 years ago

@aeldemery I take your point. My initial concern was the potential for uniquely bad consequences if a future bug results in file operations being attempted on folders that evaluate to /. It also makes it tricky to manipulate the folders with command line tools.

I think the motivation is good. Perhaps we could instead have, in the template file, a list of renamings to perform?

Prince781 commented 3 years ago

Perhaps if you could explain further an example of how dollar signs are used in Tera or other templating engines, I would change my mind.

aeldemery commented 3 years ago

Thank you for your review.

For some of the code generating tools on github which use jinja2 and tera are coockiecutter and kickstart respectively.

you are right, one should build paths using specified API rather than concatenating strings. I will update the MR. Thanks

benwaffle commented 3 years ago

sbt new (via g8) supports it http://www.foundweekends.org/giter8/template.html

Prince781 commented 3 years ago

So I'm inclined to support this PR after thinking it over. I still need you to make the changes I suggested.

aeldemery commented 3 years ago

Sorry for late answer. I pushed the required suggestions. I wanted to do some restructuring to the template code so the substitution works correctly if folders not empty.

aeldemery commented 3 years ago

@Prince781 sorry I've been busy lately. You can pick up with this PR and modify it at will or close it applying your own logic to obtain the same end result. Thank you.

Prince781 commented 3 years ago

Unfortunately I can't push directly to your branch so I've made a new branch with some modifications.

Prince781 commented 3 years ago

Closing this in favor of #8