Silhouette is a simple tool to generate projects from templates published on GitHub or any other Git repository. It's inspired from a great tool called Giter8. It's written in python, but can produce files for any programming language.
Prerequest :
- Python 3.6 or above
- pip
To install using pip :
pip install silhouette-cliTemplate repositories must reside on GitHub and be named with the suffix .slh . We’re keeping a list of already published templates in the main branch of this project.
To generate a project from an already published template (for example helkaroui/simple-flask-server.slh), you can run the following command in shell :
slh new helkaroui/simple-flask-server.slh ./We keep track of published templates on github and store them in a json file ref/templates.json.
To list the referenced templates, you can run the following command :
slh listTo create a template you should follow theses guidelines :
- the template should be published publically to github
- the repository name on github should ends with the prefix
.slh
1- Create the project directory, this directory is where you should put your files
2- Create a file named default.properties at repositroy root. This file is used to declare the project varaibles. Properties are simple keys and values that replace them.
default.properties file may be placed in project/ directory, or directly under the root of the template. Properties are simple keys and values that replace them.
use the following command to init an empty template directory :
slh init myTemplateNameWe use a simple engine that evaluates the template's properties declared in default.properties file, in all the project files and paths.
The template properties are bracketed with the $ character $. For example : a classname field might be referenced in the source as:
class $classname$:
def __init__(self):If in the interactive input we enter the property $classname$ with value MyModule, the rendered file will contain :
class MyModule:
def __init__(self):Silhouette supports formatting property fields with built-in functions. For example, the author property can be formatted in upper case with :
$author;upper$
Here are all the formatting functions available :
"upper" -> To upper case
"lower" -> To lower case
"capitalize" -> Converts the first character to upper case
"casefold" -> Converts string into lower case
"strip" -> Remove spaces in start and end of the text
"swapcase" -> Make the lower case letters upper case and the upper case letters lower case
"title" -> Converts the first character of each word to upper case