daneel
v0.1.2
Published
A cli tool for you to create a module of code from a template (e.g CURD)
Downloads
10
Readme
daneel-cli
A simple CLI for scaffolding code fragment.(A code generator from your custom template)
一个代码片段生成工具。
Who need this ?
- A lazzy guy
- Who usually write the same code (e.g CURD)
- Who can write a custom template by himself
Installation
Prerequisites: Node.js (>=4.x, 6.x preferred), npm version 3+ and Git.
$ npm install -g daneel
Usage
After you've created a project, you need lots of the same code for business modules
- From official template repository
$ cd <Your business directory>
$ daneel daneel-template[#<branch-name>]
$ Input your property pairs (label and variable)
- From other template repository
$ cd <Your business directory>
$ daneel <github-name>/<template-project-name>[#<branch-name>]
$ Input your property pairs (label and variable)
- From local template
$ cd <Your business directory>
$ daneel <Your template directory (absolute path or relative path)>
$ Input your property pairs (label and variable)
More usage: download-git-repo
Example:
$ cd ./src/view/TestDaneel
$ daneel zhouytforever/daneel-template#iview
$ Input my property pairs (label and variable)
How to custom your own template
- Your template repository or directory is all you'll get.
- All you need to care about is several tags below:
{{label}}
: A label inputed in daneel-cli.{{variable}}
: A variable inputed in daneel-cli.{{#pairs}}
: An array contains{{label}}
and{{variable}}
just like[{label: Name, variable: name}]
.{{pairs}}
: The end tag of{{#pairs}}
.
- You can write all the tags as a group wherever in your template.
Example
Template you defined :
<Form inline :label-width="100">
{{#pairs}}
<FormItem label="{{label}}" prop="{{variable}}">
<Input v-model="searchCondition.{{variable}}" />
</FormItem>
{{/pairs}}
<FormItem>
<Button type="primary" @click="onSearch">查询</Button>
<Button @click="() => { this.onSearch(true) }">重置</Button>
</FormItem>
</Form>
Command you inputed :
$ daneel daneel-template
? Please input your property label.(e.g 名字): $ 名字
? Please input your property variable.(e.g name): $ name
? Need next pair ? $ y
? Please input your property label.(e.g 名字): $ 性别
? Please input your property variable.(e.g name): $ sex
? Need next pair ? $ n
Code daneel generated :
<Form inline :label-width="100">
<FormItem label="名字" prop="name">
<Input v-model="searchCondition.name" />
</FormItem>
<FormItem label="性别" prop="sex">
<Input v-model="searchCondition.sex" />
</FormItem>
<FormItem>
<Button type="primary" @click="onSearch">查询</Button>
<Button @click="() => { this.onSearch(true) }">重置</Button>
</FormItem>
</Form>
Why is the util named as daneel
It's a util created to help code like a robot
A robot should like :