jini is a tool for manipulating configuration in INI files.
- Java 1.8 or later
- Apache Maven 3.5.3 or later
First fork the project:
$ git clone https://github.com/liscju/jini.git
Change directory to project:
$ cd jini
Next build and package the project:
$ mvn package
Copy the archived project (zip or tar.gz) to destination directory:
$ cp jini-cli/target/jini-cli-1.0.0.zip destination-path
Change directory to destination path and unpack the archive:
$ cd destination-path
$ unzip jini-cli-1.0.0.zip
$ rm jini-cli-1.0.0.zip
Similar instructions applies to tar.gz:
$ cd destination-path
$ tar xvzf jini-cli-1.0.0.tar.gz
$ rm jini-cli-1.0.0.zip
Add directory to PATH, in case of Windows use Edit the system environment variables, in UNIX-like operating system add destination path to PATH. Check whether jini is installed:
$ jini --version
Show version:
$ jini --version
jini 1.0.0
Show help:
$ jini --help
Usage: jini [-chV] [-o=FILE] [[-f=PATH] [-p=ASSIGNMENT] [-d=PATH]] [-l | -s |
-g=PATH] [FILE...]
jini - tool for manipulating configuration in INI files
[FILE...] INI configuration FILE(s).
-c, --create Create new configuration.
-d, --delete=PATH Delete properties matching PATH(s).
-f, --filter=PATH Filter properties matching PATH(s).
-g, --get=PATH Write properties matching PATH(s).
-h, --help Show this help message and exit.
-l, --list Write list of properties.
-o, --output-file=FILE Write output to FILE.
-p, --put=ASSIGNMENT Put properties matching ASSIGNMENT(s).
-s, --sections Write section names.
-V, --version Print version information and exit.
Create INI file:
$ cat << EOF > example.ini
> ; last modified 1 April 2001 by John Doe
>
> modified = 1-April-2001
> author = Mary Jane
> street =
>
> [owner] ; owner properties
> name = John Doe
> organization = Acme Widgets Inc.
> boss
>
> [database]
> ; use IP address in case network name resolution is not working
> author = John Stark
> server = 192.0.2.62
> port = 143 ; port chosen by random
> file = "payroll.dat"
>
> [database.storage]
> mount = /home/ore/fs
> server = 192.0.5.132
> EOF
Print INI file in normalized form from file:
$ jini example.ini
author=Mary Jane
street=
modified=1-April-2001
[owner]
boss=
organization=Acme Widgets Inc.
name=John Doe
[database]
server=192.0.2.62
file="payroll.dat"
port=143
author=John Stark
[database.storage]
server=192.0.5.132
mount=/home/ore/fs
Print INI in normalized form from standard input:
$ cat example.ini | jini
author=Mary Jane
street=
modified=1-April-2001
[owner]
boss=
organization=Acme Widgets Inc.
name=John Doe
[database]
server=192.0.2.62
file="payroll.dat"
port=143
author=John Stark
[database.storage]
server=192.0.5.132
mount=/home/ore/fs
Get single property from outside (default) section:
$ jini -g author example.ini
Mary Jane
Get single property value from a section:
$ jini -g owner.name example.ini
John Doe
Get multiple properties values:
$ jini -g author,owner.name,database.server example.ini
author=Mary Jane
owner.name=John Doe
database.server=192.0.2.62
Get properties from section:
$ jini -g owner example.ini
owner.boss=
owner.organization=Acme Widgets Inc.
owner.name=John Doe
Filter file for properties and section:
$ jini -f modified,author,street,owner example.ini
author=Mary Jane
street=
modified=1-April-2001
[owner]
boss=
organization=Acme Widgets Inc.
name=John Doe
Delete property and sections:
$ jini -d street,database,database.storage example.ini
author=Mary Jane
modified=1-April-2001
[owner]
boss=
organization=Acme Widgets Inc.
name=John Doe
Put properties with section:
$ jini -p street=Washers,os.name=linux,os.version=10.0 example.ini
author=Mary Jane
street=Washers
modified=1-April-2001
[owner]
boss=
organization=Acme Widgets Inc.
name=John Doe
[database]
server=192.0.2.62
file="payroll.dat"
port=143
author=John Stark
[os]
name=linux
version=10.0
[database.storage]
server=192.0.5.132
mount=/home/ore/fs
List sections:
$ jini -s example.ini
.
owner
database
database.storage
List properties:
$ jini -l example.ini
author
street
modified
owner.boss
owner.organization
owner.name
database.server
database.file
database.port
database.author
database.storage.server
database.storage.mount
Write output to file:
$ jini -f modified,author,street,owner example.ini -o result.ini
$ cat result.ini
author=Mary Jane
street=
modified=1-April-2001
[owner]
boss=
organization=Acme Widgets Inc.
name=John Doe
Get properties that property path matches path with wildcard * (matches any characters except for dots):
$ jini -g '*author' example.ini
author=Mary Jane
$ jini -g 'mod*' example.ini
modified=1-April-2001
Get properties that property path matches path with wildcard ** (matches any characters including dots):
$ jini -g '**author' example.ini
database.author=John Stark
author=Mary Jane
Join multiple INI files:
$ cat << EOF > example2.ini
> ; last modified 1 April 2005 by John Bro
>
> author = Joe Bro
>
> [owner] ; owner properties
> name = Joe Bro
>
> [root]
> name = PILI
> pass = NO
> EOF
$ jini example.ini example2.ini
author=Joe Bro
street=
modified=1-April-2001
[owner]
boss=
organization=Acme Widgets Inc.
name=Joe Bro
[database]
server=192.0.2.62
file="payroll.dat"
port=143
author=John Stark
[database.storage]
server=192.0.5.132
mount=/home/ore/fs
[root]
pass=NO
name=PILI
Create INI file with properties:
$ jini -c -p 'modified=1-April-2001,author=Mary Jane,owner.name=John Doe,owner.boss'
author=Mary Jane
modified=1-April-2001
[owner]
boss=
name=John Doe
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.