cargo-bullet 0.2.5

This is a configurable project generator
cargo-bullet-0.2.5 is not a library.

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

Known Problems

OS Problem Solve
centos Could not find directory of OpenSSL yum install openssl-devel
ubuntu linker cc not found sudo apt-get install build-essential
ubuntu Could not find directory of OpenSSL sudo apt install libssl-dev & sudo apt instll pkg-config

windows

  1. install rust: following rust-lang
  2. install bullet: cargo install cargo-bullet
  3. check version: cargo bullet --version
  • please install visual studio to get the msvc compiler

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> --template=<template_dir> --out=<out_dir>

config file example: build.toml

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

project structure example: templates/structure/structure.toml

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

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

generate the project

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

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: item_path, item_file, item_tmpl, item_type
  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:

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:

item_path = "{{context.project}}.hello" item_file = "{{resource.name_info.default_name}}"

For All User

bullet.toml example

group = "example"
project = "test"

[ext]
content = "ext content"

[resources.basic_info]
name_info = {default_name = "hello"}
type_info = {}
ext = {}
fields = [
    {name_info = {default_name = "id", camel_name="id"},  type_info= {java="Long"}},
]

bullet.toml root element

property must type
group yes string
project yes string
ext no map<string, string>
resources no resource element

resource element

property must type
name_info yes name element
type_info yes map<string, string>
ext no map<string, string>
fields yes field element

field element

property must type
name_info yes name element
type_info yes map<string, string>
ext no map<string, string>

name element

property must type
default_name yes string
snake_name no string
hyphen_name no string
upper_camel_name no string
lower_camel_name no string

Supported Templates

Java Spring

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

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