MashupMill / property-parser

Simple java application that parses a java properties file (using apache's commons-configuration) and outputs it as program arguments

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

property-parser

Simple java application that parses a java properties file (using apache's commons-configuration) and outputs it as program arguments

Build Status

Compiling

Must have maven installed

Run mvn clean package

This creates an executable jar at target/property-parser-1.0-SNAPSHOT.jar

Running

With a test.properties file like this:

foo=bar
hello=it's a foo ${foo} world

And once you have your executable jar you may then run something like this:

java -jar target/property-parser-1.0-SNAPSHOT.jar src/test/resources/test.properties -q

It should output something like this: -Dfoo=bar '-Dhello=it\'s a foo bar world'

Commands

template

The template command takes a properties file and a template file (or takes text from stdin) and does string substitution on the input using the properties file. The string substitution is done using Apache's StrSubstitutor.

You can run the template command using something like this:

java -jar target/property-parser-1.4.jar template src/test/resources/test.properties src/test/resources/template.html

It will write the output to stdout, unless you specify an -o or --out argument like this:

java -jar target/property-parser-1.4.jar template -o /tmp/output.html src/test/resources/test.properties src/test/resources/template.html

Changelog

1.6

  • Added a System.exit(0); after running the command. Apparently not having this causes issues in some kernels. I was experiencing defunct java processes in boot2docker 1.9.1.

1.5

  • Ditch commons-configuration ... didn't like how it handled the properties (i.e. first properties take precedence in some cases, and then when doing the str substitution thing it would put substitute ${foo} with [default, bar] instead of just bar. So instead just use the default java properties class and use StrSubstitutor to do nested property substitutions.
  • Bring in commons-lang3
  • Now the last properties take precedence over the first

1.4

  • Added 'command' framework
  • Added 'template' command. Which allows for replacing property placeholders in a file using Apache's StrSubstitutor.

1.3

  • Added EscapeType.NONE
  • Change default EscapeType to DOUBLE_QUOTE

1.2.1

  • Added travis-ci build

1.2

  • Move the beginning of the wrapper quotes to include the -Dkey=. So instead of -Dfoo='the bar' it becomes '-Dfoo=the bar'

1.1

  • Added escape type options:
    • -s / --slash which escapes spaces with a back slash
    • -q / --single-quote which escapes values with spaces by wrapping them in single quotes
    • -d / --double-quote which escapes values with spaces by wrapping them in double quotes
  • Default escape type is back slash (which is different from v1.0...single quotes)

1.0

  • Initial release. Parses properties file as java -D options. Escapes the values with spaces by wrapping the value in single quotes.

About

Simple java application that parses a java properties file (using apache's commons-configuration) and outputs it as program arguments

License:Apache License 2.0


Languages

Language:Java 99.1%Language:HTML 0.9%