Code Monkey home page Code Monkey logo

daneel's Introduction

daneel Build Status npm package

A simple CLI for scaffolding code fragment.(A code generator from your custom template)

Theoretically, you can generate any language code to release your hands which depends on your template

一个代码片段生成工具。

理论上,你可以用它生成任何语言的重复操作部分

Who need this ?

  1. A lazzy guy
  2. Who usually write the same code (e.g CURD)
  3. 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

  1. Your template repository or directory is all you'll get.
  2. 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}}.
  3. 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>

F.A.Q.

Q1. What about {{label}} without replacement

Just write \{{label}} wherever you want

Q2. Why is the util named as daneel

It's a util created to help code like a robot

A robot should like :

License

MIT

daneel's People

Contributors

zhouytforever avatar

Stargazers

 avatar  avatar tinwan avatar GODI13 avatar  avatar  avatar

Watchers

 avatar tinwan avatar  avatar

Forkers

18boys

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.