crates.io LICENSE Build Status

bullet

bullet is a project boilerplate generator

install

linux/unix/mac

  1. install rust: curl https://sh.rustup.rs -sSf | sh
  2. install bullet: cargo install cargo-bullet
  3. check version: cargo bullet --version

windows

  1. install rust: following rust-lang
  2. install bullet: cargo install cargo-bullet
  3. check version: cargo bullet --version

install from source

  1. install rust
  2. git clone https://github.com/thegenius/bullet.git
  3. cd bullet
  4. cargo build --release
  5. ./target/release/bullet.exe --version

usage

cargo bullet --config=\

config file example: build.toml

toml group = "example" project = "test" [ext] my_content = "This is my content"

project structure example: templates/structure/structure.toml

text project_structure = [ {item_path="{{ context.group }}.{{context.project }}", item_file = "hello.txt", item_tmpl="hello.txt.tmpl", item_type="static"} ]

project template example: templates/template/hello.txt.tmpl

text hello {{ context.project }} {{ context.ext.my_content }}

generate the project

text cargo bullet -c build.toml -t templates -o output

idea

when we develop a project, we always write many boilerplate code, config and etc. so to save your life time. 1. create a project template. 2. config the project with yaml or json or toml. 3. generate the project

For Template Developer

Template Structure

text root |-- structure/ |-- |-- structure.toml |-- template/ |-- |-- hello.tmpl |-- |-- world.tmpl |-- bullet.toml

Structrue File

  1. project_structure is the root element
  2. children element must have 4 fields: itempath, itemfile, itemtmpl, itemtype
  3. item_path is the file path that you want to generate
  4. item_file is the file name that you want to generate
  5. item_tmpl is the template file located in template dir
  6. item_type now support "static" and "dynamic"

    Static Structure

you can use context as the reference to bullet.toml properties
for example: text item_path = "{{context.project}}.hello"

Dynamic Structure

you can use context as the reference to bullet.toml properties,
and you can use resource as the reference to bullet.toml's resource item for example: text item_path = "{{context.project}}.hello" item_file = "{{resource.name_info.default_name}}"

For All User

bullet.toml example

```text group = "example" project = "test"

[ext] content = "ext content"

[resources.basicinfo] nameinfo = {defaultname = "hello"} typeinfo = {} ext = {} fields = [ {nameinfo = {defaultname = "id", camelname="id"}, typeinfo= {java="Long"}}, ] ```

bullet.toml root element

|property|must|type| |----|----|----| |group|yes|string| |project|yes|string| |ext|no|map\

resource element

|property|must|type| |----|----|----| |nameinfo|yes|name element| |typeinfo|yes|map\

field element

|property|must|type| |----|----|----| |nameinfo|yes|name element| |typeinfo|yes|map\

name element

|property|must|type| |----|----|----| |defaultname|yes|string| |snakename|no|string| |hyphenname|no|string| |uppercamelname|no|string| |lowercamel_name|no|string|

Supported Templates

Java Spring

text cargo bullet install --name=bullet-spring-java cargo bullet create --name=bullet-spring-java cargo bullet build --name=bullet-spring-java --output=out

MySQL accumulator

text cargo bullet install --name=bullet-sql-accumulator cargo bullet create --name=bullet-sql-accumulator cargo bullet build --name=bullet-sql-accumulator --output=out