A command line tool to fill Mustache templates written in Kotlin.
This project is a demo subject to show how to write a command line tool from the first line of code to the installation on the user system.
Slides are available at : http://slides.com/ekino-leomillon/oh-my-mustache
Fill a simple template :
$ oh-my-mustache --template "Hi {{name}} !" --variable name "John Doe"
Hi John Doe !
Or using template/context files :
template.mustache
Hi {{contact.firstname}} {{contact.lastname}} !
You have these events today :
{{#events}}
- {{title}}
{{/events}}
context.json
{
"contact": {
"lastname": "Doe",
"firstname": "John"
},
"events": [
{
"title": "Meeting 1"
},
{
"title": "Meeting 2"
}
]
}
$ oh-my-mustache --template-file ./template.mustache --context-file ./context.json
Hi John Doe !
You have these events today :
- Meeting 1
- Meeting 2
You can tap the ekino repository ekino/formulas to install oh-my-mustache.
Just use the following commands :
brew tap ekino/formulas
brew install oh-my-mustache
ℹ️ Bash / ZSH auto completion will be installed but may not be activated/loaded. Please follow the instructions written during the homebrew installation or jump the the manual installation section.
First step, you have to download the latest release (oh-my-mustache-VERSION.zip
or oh-my-mustache-VERSION.tar
files) on this page.
Once the archive has been uncompressed, you will find the oh-my-mustache
script in the bin
directory.
Go into the bin
directory and try the following command to get the global help :
./oh-my-mustache --help
You can source the script ohmymustache-completion.bash
in the completion
directory :
source completion/ohmymustache-completion.bash
If you want enable it permanently, you will have to load it with your profile. Add the following line to your ~/.bash_profile
or ~/.zshrc
and replace PATH_TO_TOOL
with the location of the oh-my-mustache uncompressed folder.
[ -f PATH_TO_TOOL/completion/ohmymustache-completion.bash ] && source PATH_TO_TOOL/completion/ohmymustache-completion.bash
ℹ️ ZSH users : you may need to add these two lines before the previous one to enable the bash completion :
autoload -U compinit && compinit
autoload -U bashcompinit && bashcompinit
Once the archive has been uncompressed, you will find the oh-my-mustache.bat
script in the bin
directory.
Go into the bin
directory and try the following command to get the global help :
oh-my-mustache.bat --help