Git Product home page Git Product logo

bonebroth's Introduction

BoneBroth

Build Status

BoneBroth is a text generator using Apache Velocity and some config libraries.

BoneBroth requires JRE 8 or later.

Supported config libraries are as follows:

  • YAML (SnakeYAML)
  • TypeSafeConfig
  • CSV and TSV (Apache Commons CSV + custom format)
  • Properties (java.util.Properties)

See the project's wiki page for further information.

To Install

Run the following command.

$ curl -fsSL http://bit.ly/instbonebroth | sh

or

$ curl -fsSL https://goo.gl/N7PttL | sh

Both of these urls are shortened of https://raw.githubusercontent.com/argius/bonebroth/master/install.sh.

To uninstall, remove $(which bonebroth).

You need only to download, see the releases page.

Usage

Run the following command.

$ bonebroth --help

Examples

Input Files

  • example.vm
/*
 * This code has been generated by $generator.
 */
package $package;

/**
 * ${classDescription}.
 *
 * @author $author.name
 */
public final class $className {

    /*
     * comment:
     * numbers =#foreach( $i in $a.numbers )#set( $j=$i+1 ) [$j]#end

     */

#foreach( $item in $items )
    private $item.type $item.id.camel;
#end

    public $className() {
#foreach( $item in $items )
        this.$item.id.camel = $item.value;
#end
    }
#foreach( $o in $items )
  #set( $id = $o.id )

    /**
     * $m.message("template.getter", $o.name)
     * @return $o.name
     */
    public $o.type get${id.pascal}() {
        return $id.camel;
    }

    /**
     * $m.message("template.setter", $o.name)
     * @param $id.camel value to set
     */
    public void set${id.pascal}($o.type $id.camel) {
        this.$id.camel = $id.camel;
    }
#end

}
  • example.csv
@className,Example
@package,bonebroth
@classDescription,Example of BoneBroth
# comment
# id, type, name, value
EXAMPLE_MESSAGE,String,example message,"""hello"""
VALUE_NUMBER,int,a number of value,3
END_OF_DATA,boolean,end of data,false
  • example.conf (TypeSafeConfig)

a.numbers=[2,3,5]

author : {
  name : "argius"
}

Command to run and Result

  • normal mode
$ bonebroth -t example.vm -i example.csv,example.conf
/*
 * This code has been generated by BoneBroth version 1.1.0 [build #25 on 2018-02-02T11:20:38Z].
 */
package bonebroth;

/**
 * Example of BoneBroth.
 *
 * @author argius
 */
public final class Example {

    /*
     * comment:
     * numbers = [3] [4] [6]
     */

    private String exampleMessage;
    private int valueNumber;
    private boolean endOfData;

    public Example() {
        this.exampleMessage = "hello";
        this.valueNumber = 3;
        this.endOfData = false;
    }

    /**
     * Gets example message.
     * @return example message
     */
    public String getExampleMessage() {
        return exampleMessage;
    }

    /**
     * Sets example message.
     * @param exampleMessage value to set
     */
    public void setExampleMessage(String exampleMessage) {
        this.exampleMessage = exampleMessage;
    }

    /**
     * Gets a number of value.
     * @return a number of value
     */
    public int getValueNumber() {
        return valueNumber;
    }

    /**
     * Sets a number of value.
     * @param valueNumber value to set
     */
    public void setValueNumber(int valueNumber) {
        this.valueNumber = valueNumber;
    }

    /**
     * Gets end of data.
     * @return end of data
     */
    public boolean getEndOfData() {
        return endOfData;
    }

    /**
     * Sets end of data.
     * @param endOfData value to set
     */
    public void setEndOfData(boolean endOfData) {
        this.endOfData = endOfData;
    }

}
  • bean mode
$ bonebroth --bean -i example.csv
package bonebroth;

/**
 * Example of BoneBroth.
 */
public final class Example {

    /** example message */
    private String exampleMessage;

    /** a number of value */
    private int valueNumber;

    /** end of data */
    private boolean endOfData;

    /**
     * .
     */
    public Example() {
        // empty
    }

    /**
     * Gets example message.
     * @return example message
     */
    public String getExampleMessage() {
        return exampleMessage;
    }

    /**
     * Sets example message.
     * @param exampleMessage value to set
     */
    public void setExampleMessage(String exampleMessage) {
        this.exampleMessage = exampleMessage;
    }

    /**
     * Gets a number of value.
     * @return a number of value
     */
    public int getValueNumber() {
        return valueNumber;
    }

    /**
     * Sets a number of value.
     * @param valueNumber value to set
     */
    public void setValueNumber(int valueNumber) {
        this.valueNumber = valueNumber;
    }

    /**
     * Gets end of data.
     * @return end of data
     */
    public boolean isEndOfData() {
        return endOfData;
    }

    /**
     * Sets end of data.
     * @param endOfData value to set
     */
    public void setEndOfData(boolean endOfData) {
        this.endOfData = endOfData;
    }
}

TIPS

Running BoneBroth without input files

Set a comma alone to the --input option.

$ bonebroth -t $0 -i ,

Running BoneBroth like a script

  • generator-script
#*
/usr/bin/env bonebroth -t $0 -i ,
exit $?; *###
$util.enrich("BoneBroth").chain
  • Running this script
$ chmod +x generator-script
$ ./generator-script
bone-broth

License

Apache 2.0 License.

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.