How I reuse a existing project as a template effectively?
Simple yet powerful code generator. Make use of existing tool as possiable as we can.
Small features:
- template is runable as normal prj. No more %placehold% stuff.
- respect .gitignore.
- support github.com repo.
- plugin in any language only if you can run it in shell.
- respect Old keyword case.
install
pip3 install coge
usage
put this line in your ~/.bash_profile, and change the your_template_folder to the folder where you put your templates.
export COGE_TMPLS="<your_template_folder>"
demo 1
coge js react oldkey:newkey :newkey0 :newkey1 @:destname
# What coge does:
# - copy $COGE_TMPLS/js/react to $PWD/destname
# - change all names from oldkey to newkey, from COGE_ARG_0 to newkey0 ,from COGE_ARG_1 to newkey1
demo 2
coge js react
# What coge does:
# - Just copy $COGE_TMPLS/js/react to $PWD/app
advanced tricks (optional)
work with fzf
cg () {
eval `coge -c $@ | fzf --preview= --bind 'enter:execute-silent(pbcopy <<< {})+abort' ` && pbpaste
}
call cg from terminal. and paste it.
hook script
you can put .coge.after.sh in you template folder.
It will execute after copy, which is very handy.
For Safety reason. Template from network would need to use -s option to enforcing script executing, only if you know the script is safe.
Supported timing and language:
.coge.after.sh
.coge.before.sh
.coge.after.py
.coge.before.py
Ex: put .coge.after.sh in your source template
#!/bin/bash
echo "init your git repo"
git init
.coge.json
Sometimes we do not remember what the string we should repalce,
put a .coge.json in your template project.
coge would respect this json file to verify all replacements.
It is just a array with two types, map or string.
all elements in the array must be fullfilled when doing the replacements.
If some strings to be replaced are missed in the command line. Coge would automatically prompt up for user to supply.
I think the configuration explains for itself.
[
{
"key": "cli",
"desc": "this is blala"
},
"projectname"
]
help
usage: coge [-h] [-a ARG_PREFIX] [-l] [-c] [-r] [-R] [-s] [-d DEPTH] [-v]
[magic ...]
make template link : cd x-engine-module-template && coge -r
use template : coge x-engine-module-template xxxx:camera @:x-engine-module-camera
use git template from net : coge https://www.github.com/vitejs/vite \bvite\b:your_vite @:your_vite
positional arguments:
magic newkey:oldkey or @:folder_name
optional arguments:
-h, --help show this help message and exit
-a ARG_PREFIX, --arg_prefix ARG_PREFIX
ex: COGE_ARG_
-l, --list list folders
-c, --cmd cmd
-r, --link_tplt link `cwd` to $COGE_TMPLS
-R, --unlink_tplt unlink `cwd`
-s, --script_from_net
alllow script from net
-d DEPTH, --depth DEPTH
list depth
-v, --version version
Metadata
Release files for coge 0.1.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| coge-0.1.9-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for coge-0.1.9-py2.py3-none-any.whl |
Release files / coge-0.1.9-py2.py3-none-any.whl
| Download URL | coge-0.1.9-py2.py3-none-any.whl |
|---|---|
| Size | 11.7 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
ffcd588397ee8dd2a4386502fc4b5d99370254d2e20268f97df28d8635a9460f
|
|
BLAKE2b-256 checksum How to use checksums |
728f6faeea48e90157890924fe7cfc2ac7a23233c503048c9159dd2b8ea689e8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.7
|
Security for coge 0.1.9
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.