bullet
bullet is a project boilerplate generator
install
linux/unix/mac
- install rust: curl https://sh.rustup.rs -sSf | sh
- install bullet: cargo install cargo-bullet
- 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
- install rust: following rust-lang
- install bullet: cargo install cargo-bullet
- check version: cargo bullet --version
- please install visual studio to get the msvc compiler
install from source
- install rust
- git clone https://github.com/thegenius/bullet.git
- cd bullet
- cargo build --release
- ./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.
- create a project template.
- config the project with yaml or json or toml.
- generate the project
For Template Developer
Template Structure
root |-- structure/
|-- |-- structure.toml
|-- template/
|-- |-- hello.tmpl
|-- |-- world.tmpl
|-- bullet.toml
Structrue File
- project_structure is the root element
- children element must have 4 fields: item_path, item_file, item_tmpl, item_type
- item_path is the file path that you want to generate
- item_file is the file name that you want to generate
- item_tmpl is the template file located in template dir
- 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 Gradle
cargo bullet install --name=bullet-spring-java
cargo bullet create --name=bullet-spring-java
cargo bullet build --name=bullet-spring-java --output=out
Java Spring Maven
cargo bullet install --name=bullet-spring-java-maven
cargo bullet create --name=bullet-spring-java-maven
cargo bullet build --name=bullet-spring-java-maven --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