iomentum / cargo-scaffold

cargo scaffold lets you scaffold and generate projects described in a simple TOML file
MIT License
57 stars 12 forks source link

Add support for using parameter values in creating directories #44

Closed gabhijit closed 1 year ago

gabhijit commented 1 year ago

Let's say I have the following directory structure in a template directory -

template
 | 
 + - {{dir_name}}-00
   | 
   + - example.txt 

and my .scaffold.toml file looks like following

name = "example" 
# Omitted for brevity ...

[parameters]
  [parameters.dir_name]
  type = "string"
  message = "Enter the value for directory name."
  required = true
  default = "default-directory"

When I run cargo scaffold templates/ -n example, this should generate following directory structure -

example
  | 
  + - default-directory-00
      | 
      + - example.txt

This is supported by ffizer and cargo generate as well. May be it's already supported but then not documented properly. I quickly tried this with a simple template, but it generates the directory with {{dir_name}}-00 directory name and not the rendered name,

gabhijit commented 1 year ago

In fact render_path already exists. Needs a really small fix to make this available during creating a directory. Sending a PR for that.

gabhijit commented 1 year ago

Fixed by #45