A directory-based, easy-to-use code generator that integrates seamlessly with your project.
- Each folder represents a new template.
- Every folder must include a
template.json
file to define the template's rules and parameters.
See test directory.
The template.json
file includes:
- Description (
desc
): Metadata about the template. - Rules (
rules
): Defines how files are created or updated. Rules can also reference other templates (template/template
), starting always with the temp. - Parameters (
parameters
): Inputs required by the template, such as:free
: Simple inline text.select
: A list of options.formatted
: Textarea-like input.
{
"desc": {
"name": "Template Name",
"description": "Template Description"
},
"rules": [
{
"rule": "{{name}}Activity.java -> ./features/{{feature}}",
"condition": ""
},
{
"rule": "template -> package",
"condition": "name==Login"
}
],
"parameters": [
{
"id": "name",
"desc": "The name of the service. Ex: BananaService",
"regex": "ˆ*Service",
"type": "free",
"required": true
},
{
"id": "type",
"desc": "The type of data exchange",
"regex": "",
"type": "select",
"required": false,
"options": ["GET", "POST", "PUT", "DELETE"]
},
{
"id": "objectOut",
"desc": "The output object",
"type": "formatted",
"required": true,
"condition": "data_exchange==BODY"
}
]
}
- Each folder should include the template files used for creation or modification.
.n
(New Files): Used when the target file does not exist..e
(Edit Files): Used when updating an existing file.
For example: Main.java.e
, Main.java.n
, Main.svelte.e
.
- Use
{{PARAM_NAME}}
to reference a parameter. - Use
{%if(condition)%}...{%endif%}
to apply conditions.
Example .n
File:
package co.vm.features.{{feature}};
import co.vm.features.apis.Api;
// New imports come here
public class {{feature}}Services {
// Service {{name}} {{feature}}
public void {%if(type=="GET")%}fetch{{name}}{%endif%}{%if(type=="POST")%}post{{name}}{%endif%}() {
return {{objectOut}};
}
// New services come here
}
- Use
@@
followed by a regex to define insertion points. - Use
-@@
to mark the end of a block.
Example .e
File:
@@// New Services come here
// Service {{name}} {{feature}}
public void {%if(type=="GET")%}fetch{{name}}{%endif%}{%if(type=="POST")%}post{{name}}{%endif%}() {
// ...
}
-@@
@@// New Declarations come here
// {{name}} {{feature}}
-@@
- Add the
wizzy
binary to the root of your project. - Create a
.wizzy
folder and start defining your templates and rules.
Run the following command in your terminal:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/MJAZ93/wizzy/main/build/remote-mac.sh)"
Wizzy is distributed under the Fair Code License.