Skip to content

Latest commit

 

History

History
173 lines (120 loc) · 4.28 KB

cli.md

File metadata and controls

173 lines (120 loc) · 4.28 KB

CLI Options


Copy a Repository

tmplr owner/repo

Copies content of given repository on GitHub to current directory, and runs its recipe, if exists (checks for .tmplr.yml file). This basically clones https://github.com/owner/repo.git. You can also specify repositories from GitLab, BitBucket or SourceHut:

# 🥽 download from GitLab
tmplr gitlab:owner/repo
tmplr git@gitlab.com:owner/repo
tmplr https://gitlab.com/owner/repo

# 🪣 download from BitBucket
tmplr bitbucket:owner/repo
tmplr git@bitbucket.org:owner/repo
tmplr https://bitbucket.org/owner/repo

# 🛖 download from Sourcehut
tmplr git.sr.ht/owner/repo
tpmlr git@git.sr.ht:owner/repo
tpmlr https://git.sr.ht/owner/repo

You can specify a tag, branch, commit or subdirectory:

tmplr owner/repo#branch       # 👉 branch
tmplr owner/repo#tag          # 👉 release tag
tmplr owner/repo#c0m1th45h    # 👉 commit hash
tmplr owner/repo/subdirectory # 👉 sub directory

Working directory

Use -d or --dir option to specify a working directory. tmplr will copy the repository to the given directory (creating all necessary directories) and runs the recipe from there:

tmplr owner/repo -d my-project

Run Local Recipe

tmplr

If you already have the recipe file in current directory, you can run it with tmplr command without any arguments. This will parse and execute .tmplr.yml file in current directory. You can specify a working directory with -d or --dir option:

tmplr -d my-project

Which will run .tmplr.yml file located inside my-project directory, in the same project.


Run a Reusable Recipe

tmplr use owner/repo

Copies content of given repository to a temporary directory, runs its recipe, and then removes the directory. Reusable recipes can be used to alter an existing project in specific ways. For example, you can use this recipe to add a license file to your project:

tmplr use trcps/license

💡 use command accepts all the same arguments as for copying a repo:

tmplr use owner/repo#branch
tmplr use gitlab:owner/repo
tmplr use owner/repo -d my-project
tmplr use local:some/recipe
...

Testing recipes

tmplr preview

Will copy the contents of current directory into .tmplr-preview/<dir> and runs the recipe file (<dir> is the name of current directory). This is useful for testing recipes before publishing them. You can specify a working directory with -d or --dir option:

tmplr preview -d my-project

Which will copy the contents of my-project directory into my-project/.tmplr-preview/my-project and runs the recipe file.


If you are working on a reusable recipe, you can preview the result of running it (without any arguments) using preview:use command:

tmplr preview:use

This will treat contents of working directory as a reusable recipe, running it inside .tmplr-preview directory. To be more specific: this command will copy the contents of working directory into a temporary subdirectory of .tmplr-preview, run .tmplr.yml, and then remove the temporary subdirectory, emulating what happens when someone uses your recipe either via use command in a recipe or via the CLI.


You can cleanup testing artifacts using tmplr clean command:

tmplr clean
tmplr clean -d my-project

Miscellaneous

Version & Updates

tmplr version
tmplr -v

Displays current version of tmplr, and checks the latest version to see if an update is necessary. If you have tmplr installed locally, you can update it with:

npm i -g tmplr@latest

If you use it via npx, you can ensure the latest version is run via:

npx tmplr@latest

Help

tmplr help
tmplr -h

Displays help message.