ini-merge
v1.0.2
Published
INI cli-tool for merging multiple files into one
Downloads
5
Readme
ini-merge
Installation
npm install --global ini-merge
Usage
ini-merge input.ini output.ini
Examples
Merging sections
input.ini
[list]
1=a
2=b
[list]
3=c
4=d
output.ini
[list]
1=a
2=b
3=c
4=d
Auto generated keys
input.ini
[list]
1=a
2=b
*=c
*=d
[list]
*=e
*=f
output.ini
[list]
1=a
2=b
3=c
4=d
5=e
6=f
Importing other files / Splitting large file to multiple files
input.ini
;#import part1.ini
;#import part2.ini
part1.ini
[part1]
key=value
part1.ini
[part2]
key=value
output.ini
[part1]
key=value
[part2]
key=value
Defining variables
input.ini
;@v1 100
;@v2 200
[data]
v1=@v1
v2=@v2
v3=@v1 and @v2
output.ini
[data]
v1=100
v2=200
v3=100 and 200
Using @current variable
input.ini
[section1]
data=1
[section2]
; the key 'data' does not present
; overwrite of section1
[section1]
data=@current,2
;overwrite of section2
[section2]
data=@current,2
output.ini
[section1]
data=1,2
[section2]
; no comma before '2'
data=2
Appending section name as a key of another section
input.ini
[list]
1=item1
2=item2
[item3]
;#appendTo list
[item4]
;#appendTo list
output.ini
[list]
1=item1
2=item2
3=item3
4=item4
Removing specified section keys
input.ini
[data]
key1=1
key2=2
key3=3
[data]
;#remove key1,key3
key4=4
output.ini
[data]
key2=2
key4=4
Removing all section keys
input.ini
[data]
key1=1
key2=2
key3=3
[data]
;#remove *
key4=4
output.ini
[data]
key4=4
Ignoring section rendering
input.ini
[data]
;#virtual
key=value
output.ini
; section 'data' does not render
Extending sections
input.ini
[section1]
key1=1
key2=2
[section2]
; using #virtual to hide this section
;#virtual
key1=2;
key3=3
key4=4
[section3]
;#extends section1,section2
; overwrite key4
key4=5
output.ini
[section1]
key1=1
key2=2
[section3]
key1=2
key2=2
key3=3
key4=5
Creating and applying template
input.ini
; global variable
;@param3 3
[my-template]
; indicate this section acts like template and the template has 2 params
; templated section will not render to output
;#template param1,param2
key1=@param1
key2=@param2
key3=@param3
[use-case-1]
; apply template with specified params
;#apply my-template @begin
param1=p1
param2=p2
;@end
[use-case-2]
; apply template with specified params
;#apply my-template @begin
param1=p1
; no param2
;@end
[use-case-3]
; apply template with no param
;#apply my-template
output.ini
[use-case-1]
key1=p1
key2=p2
key3=3
[use-case-2]
key1=p1
key2=
key3=3
[use-case-3]
key1=
key2=
key3=3
Using conditional block
Dynamic section name
input.ini
;@section-name MySection
[@section-name]
output.ini
[MySection]