README
iniedit
Introduction
The iniedit utility is a small program for adding, updating, and deleting
sections and/or entries in Common INI Format files. It provides a Javascript
API and command-line interface, and allows for conditional criteria to be
specified as preconditions for any section modification, addition, or deletion
operation.
This repository is a work in progress and absolutely should not be used in production at this time.
CLI Quick Start
In addition to an ES7 Javascript API, this package provides a fully-functional
command-line executable called iniedit, which is suitable for small one-off
modification of INI files. To get started, run npm i @castlelemongrab/iniedit,
then iniedit -h, iniedit add -h, iniedit delete -h, or iniedit modify -h
to view built-in documentation.
Example: Build an INI file from /dev/null
iniedit add -f /dev/null \
-s Section -l A=1 -l B=2 -c Comment > my.ini
[Section]
# Comment
A = 1
B = 2
Example: Conditionally add a new INI section
If a section named Section exists with property values A = 1 and B = 2,
then add a new section named Section #2 with properties A = 2 and B=3.
iniedit add \
-f my.ini -x Section -n A=1 -n B=2 -s 'Section #2' -l A=2 -l B=3
[Section]
# Comment
A = 1
B = 2
[Section #2]
A = 2
B = 3
Example: Adding a property to multiple sections
Regular expressions can be used to match section names, property names, and
property values. This example adds or replaces an INI line (N.B. section
property) named Type in any INI file section that begins with Section.
iniedit modify -f my.ini \
-r -x '^Section.*' -l Type=Awesome
[Section]
# Comment
A = 1
B = 2
Type = Awesome
[Section #2]
A = 2
B = 3
Type = Awesome
Example: Deleting a section with regular expressions
Regular expressions can be used to match section names, property names, and property values. This example seletes an INI section thst has a certain matching property value; the key is ignored.
iniedit delete -f my.ini \
-r -n '.*=3'
[Section]
# Comment
A = 1
B = 2
Type = Awesome
Example: Editing properties
This example adds a new key/value pair and comment to any section that starts
with Section and has a Type of Awesome.
iniedit modify -f my.ini -r \
-x '^Section.*