coge


Namecoge JSON
Version 0.1.9 PyPI version JSON
download
home_pagehttps://github.com/zk4/coge
Summarythis is a description
upload_time2023-06-09 10:49:55
maintainer
docs_urlNone
authorzk
requires_python>3.0.0
licenseBSD
keywords best practice for python project
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            > How I reuse a existing project as a template effectively? 

![image-20210312140113821](https://raw.githubusercontent.com/zk4/image_backup/main/img/image-20210312140113821.png)

Simple yet powerful code generator.
Make use of existing tool as possiable as we can.

**Small features:**
1. template is runable as normal prj. No more %placehold% stuff.
3. respect .gitignore.
3. support github.com repo.
5. plugin in any language only if you can run it in shell.
7. 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
``` bash
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
``` bash
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.
``` json
[
  {
   "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
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/zk4/coge",
    "name": "coge",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">3.0.0",
    "maintainer_email": "",
    "keywords": "best practice for python project",
    "author": "zk",
    "author_email": "liuzq7@gmail.com",
    "download_url": "https://github.com/zk4/coge/archive/master.zip",
    "platform": null,
    "description": "> How I reuse a existing project as a template effectively? \n\n![image-20210312140113821](https://raw.githubusercontent.com/zk4/image_backup/main/img/image-20210312140113821.png)\n\nSimple yet powerful code generator.\nMake use of existing tool as possiable as we can.\n\n**Small features:**\n1. template is runable as normal prj. No more %placehold% stuff.\n3. respect .gitignore.\n3. support github.com repo.\n5. plugin in any language only if you can run it in shell.\n7. respect Old keyword case. \n\n# install\n```\npip3 install coge\n```\n\n# usage\nput this line in your `~/.bash_profile`, and change the `your_template_folder` to  the folder where you put your templates.\n```\nexport COGE_TMPLS=\"<your_template_folder>\"\n```\n\n## demo 1\n``` bash\ncoge js react oldkey:newkey :newkey0 :newkey1 @:destname \n\n# What coge does:\n# - copy $COGE_TMPLS/js/react to $PWD/destname\n# - change all names from oldkey to newkey,  from  COGE_ARG_0 to newkey0 ,from  COGE_ARG_1 to newkey1\n\n```\n## demo 2\n``` bash\ncoge js react\n# What coge does:\n# - Just copy $COGE_TMPLS/js/react to $PWD/app\n```\n\n\n# advanced tricks (optional)\n\n## work with fzf\n``` \ncg () {\n\teval `coge -c $@ | fzf --preview= --bind 'enter:execute-silent(pbcopy <<< {})+abort' ` && pbpaste\n}\n```\ncall cg from terminal. and paste it.\n## hook script\nyou can put .coge.after.sh in you template folder. \n\nIt will execute after copy, which is very handy.\n\nFor Safety reason. Template from network would need to use -s option to enforcing script executing, only if you know the script is safe.\n\nSupported timing and language:\n```\n.coge.after.sh\n.coge.before.sh\n\n.coge.after.py\n.coge.before.py\n```\n\nEx:\nput .coge.after.sh in your source template\n```\n#!/bin/bash\necho \"init your git repo\"\ngit init \n```\n\n## .coge.json \nSometimes we do not remember what the string we should repalce,\nput a `.coge.json` in your template project.\ncoge would respect this json file to verify all replacements. \nIt is just a array with two types, map or string.\nall elements in the array must be fullfilled when doing the replacements.\nIf some strings to be replaced are missed in the command line. Coge would automatically prompt up for user to supply.\n\nI think the configuration explains for itself.\n``` json\n[\n  {\n   \"key\": \"cli\",\n   \"desc\": \"this is blala\"\n  },\n  \"projectname\"\n]\n```\n\n\n# help\n```\nusage: coge [-h] [-a ARG_PREFIX] [-l] [-c] [-r] [-R] [-s] [-d DEPTH] [-v]\n            [magic ...]\n\n       make template link : cd x-engine-module-template && coge -r \n             use template : coge x-engine-module-template xxxx:camera @:x-engine-module-camera  \nuse git template from net : coge https://www.github.com/vitejs/vite \\bvite\\b:your_vite @:your_vite  \n    \n\npositional arguments:\n  magic                 newkey:oldkey or @:folder_name\n\noptional arguments:\n  -h, --help            show this help message and exit\n  -a ARG_PREFIX, --arg_prefix ARG_PREFIX\n                        ex: COGE_ARG_\n  -l, --list            list folders\n  -c, --cmd             cmd\n  -r, --link_tplt       link `cwd` to $COGE_TMPLS\n  -R, --unlink_tplt     unlink `cwd`\n  -s, --script_from_net\n                        alllow script from net\n  -d DEPTH, --depth DEPTH\n                        list depth\n  -v, --version         version\n```\n",
    "bugtrack_url": null,
    "license": "BSD",
    "summary": "this is a description",
    "version": "0.1.9",
    "project_urls": {
        "Download": "https://github.com/zk4/coge/archive/master.zip",
        "Homepage": "https://github.com/zk4/coge"
    },
    "split_keywords": [
        "best",
        "practice",
        "for",
        "python",
        "project"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "728f6faeea48e90157890924fe7cfc2ac7a23233c503048c9159dd2b8ea689e8",
                "md5": "fa742d724165f8d6a9d66d0d5bf728a2",
                "sha256": "ffcd588397ee8dd2a4386502fc4b5d99370254d2e20268f97df28d8635a9460f"
            },
            "downloads": -1,
            "filename": "coge-0.1.9-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "fa742d724165f8d6a9d66d0d5bf728a2",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">3.0.0",
            "size": 11664,
            "upload_time": "2023-06-09T10:49:55",
            "upload_time_iso_8601": "2023-06-09T10:49:55.840947Z",
            "url": "https://files.pythonhosted.org/packages/72/8f/6faeea48e90157890924fe7cfc2ac7a23233c503048c9159dd2b8ea689e8/coge-0.1.9-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-06-09 10:49:55",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "zk4",
    "github_project": "coge",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "coge"
}
        
zk
Elapsed time: 0.08464s