andrejlamov / project-templates

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Given a project template folder with variables in paths and content

tree test-project
test-project
└── %NAME1%
    └── %NAME2%
        └── %NAME2%-hello.txt

2 directories, 1 file
cat test-project/%NAME1%/%NAME2%/%NAME2%-hello.txt
Test project

%NAME1%.%NAME2%

%GREET%

How are you?

Now run template.sh with variables set in the environment and a path to a template folder

mkdir -p hello
cd hello
NAME1=src NAME2=andrej/lamov GREET='hello world' ../template.sh ../test-project

It outputs some info…

Source template:
  /home/andrej/code/template/test-project
Target:
  /home/andrej/code/template/hello
Variables:
  GREET=hello world
  NAME1=src
  NAME2=andrej/lamov
Using sed:
   -e 's\%GREET%\hello world\g' -e 's\%NAME1%\src\g' -e 's\%NAME2%\andrej/lamov\g'
Copying:
  %NAME1%/%NAME2%/%NAME2%-hello.txt -> src/andrej/lamov/andrej/lamov-hello.txt

And it results in the following structure

tree hello
hello
└── src
    └── andrej
        └── lamov
            └── andrej
                └── lamov-hello.txt

4 directories, 1 file
cat hello/src/andrej/lamov/andrej/lamov-hello.txt
Test project

src.andrej/lamov

hello world

How are you?

About

License:The Unlicense


Languages

Language:Shell 62.5%Language:Nix 37.5%