bbugyi200 / cookie Goto Github PK
View Code? Open in Web Editor NEWA Template-based File Generator. Like cookiecutter but works with file templates instead of project templates.
License: MIT License
A Template-based File Generator. Like cookiecutter but works with file templates instead of project templates.
License: MIT License
This should only be done after #19 is resolved, since it is only at that point that cookie can be considered a true alternative to cookiecutter.
This will not include additional functionility, but will instead just be another way to specify the necessary command-line options. I was hoping to implement something similar to what plop does when run with no arguments.
Example: cookie -r TEMPLATE
should delete TEMPLATE
[/tmp]$ cookie -l
dirname: illegal option -- l
usage: dirname path
basename: illegal option -- l
usage: basename string [suffix]
basename [-a] [-s suffix] string [...]
[ERROR] Template does not exist: /Users/xxx/.cookiecutters/d,c,D:,e:,f,F:,h,l,m:,r:,v,x
any command gives this ^
So basically,. it seems that the variable substitution is always adding quotes, whether they are needed or allowed in the resulting config file or not. That's not ideal.
The template
.cookiecutter/template.yml
--- # yaml file, that does not need quotes around variables
variable: {{ VARIABLE }}
The input
cookie -T template.yml -f my.yml
>>> Found matching template: template.yml
>>> Initializing the '/root/my.yml' script.
VARIABLE: typed_input
The output
--- # yaml file, that does not need quotes around variables
variable: "typed_input"
For example, running cookie -T c.mk Makefile -T gtest.mk tests/Makefile
should initialize the two templates Makefile
and tests/Makefile
and open them both up in an editor.
When #16 is finished, the above example command would instead look like this:
cookie c.mk:Makefile gtest.mk:tests/Makefile
The corresponding short-option could be -T
. This option would accept a mandatory argument which must be a sub-directory of the configured cookie template directory. This option can be used in one of two ways:
cookie -T mydir
would prompt the user for a project_name
and then create a new directory named project_name
which mirrors mydir
. Next, each file in the new directory would be processed by cookie's template rendering engine and opened in an editor (one at a time).
cookie -T mydir template:target
would initialize target
using the template mydir/template
.
Something like -m MODE
would be nice. This would make the -x
option equivalent to -m +x
.
I was testing out cookie to see what I could do with it and after a few tests I accidentally left a variable name with spaces which caused a bad substitution error.
'''
Initializing the './/doc.sh' script.
DATE:
/home/magpie/.local/bin/cookie: line 384: ${{Script Name}}: bad substitution
{{Script Name}}:
'''
This is in Ubuntu 19.04, bash 5.0.3, and current master for cookie.
While it's not unusual for variables to require no spaces it'd be good to have a failsafe in place.
This is a great tool but having to use sudo make it non-usable in controlled environments, if this could be run from a clone directory that would be phenomenal
For example, cookie --init Makefile template.mk
will copy Makefile
to the cookie template directory, rename it to template.mk
and then open it up in an editor.
For example, cookie -e foo.py bar.py
should open up both templates in an editor.
For example, cookie tempA:dirA/targA @tempB:targB:modeB tempC
will:
dirA
if it does not already exist.dirA/targA
using the tempA
template.targB
using the tempB
template.targB
to modeB
(using chmod
).tempC
using the same name for the template and target.dirA/targA
and tempC
(the target version) in an editor.Currently, the only OS tested is Linux.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.