mirror of
https://github.com/chenasraf/dotfiles.git
synced 2026-05-17 17:28:07 +00:00
41 lines
826 B
Bash
Executable File
41 lines
826 B
Bash
Executable File
#!/usr/bin/env zsh
|
|
|
|
SCAFFOLDS_DIR="$DOTFILES/scaffolds"
|
|
|
|
# scaffold a project from a template
|
|
tpl() {
|
|
if [[ "$1" == "-h" || "$1" == "--help" ]]; then
|
|
echo "Usage: tpl <template> [name] [args...]"
|
|
echo "Scaffold a project from a template"
|
|
echo "Aliases: ef=editorfile, gh=github, ghp=github.pnpm"
|
|
return 0
|
|
fi
|
|
declare -A tpl_aliases=(
|
|
ef "editorfile"
|
|
gh "github"
|
|
ghp "github.pnpm"
|
|
)
|
|
declare -A tpl_no_name=(
|
|
editorfile "1"
|
|
gh "1"
|
|
ghp "1"
|
|
)
|
|
key=$1
|
|
shift
|
|
args="$@"
|
|
if [[ ! -z "${tpl_aliases[$key]}" ]]; then
|
|
key=${tpl_aliases[$key]}
|
|
fi
|
|
|
|
if [[ "${tpl_no_name[$key]}" -eq 1 ]]; then
|
|
name="$args -"
|
|
else
|
|
if [[ -z "$args" ]]; then
|
|
echo_red "Usage: tpl $key <name>"
|
|
return 1
|
|
fi
|
|
fi
|
|
|
|
simple-scaffold -g chenasraf/templates -k $key $args
|
|
}
|