All Projects → dbohdan → initool

dbohdan / initool

Licence: MIT license
Manipulate INI files from the command line

Programming Languages

Standard ML
205 projects
shell
77523 projects
Batchfile
5799 projects
Makefile
30231 projects

Projects that are alternatives of or similar to initool

config-parser
A slim, fully managed C# library for reading/writing .ini, .conf, .cfg etc configuration files.
Stars: ✭ 67 (+67.5%)
Mutual labels:  ini, configuration-file
parse it
A python library for parsing multiple types of config files, envvars & command line arguments that takes the headache out of setting app configurations.
Stars: ✭ 86 (+115%)
Mutual labels:  ini, configuration-file
Structured Text Tools
A list of command line tools for manipulating structured text data
Stars: ✭ 6,180 (+15350%)
Mutual labels:  ini, configuration-file
libconfini
Yet another INI parser
Stars: ✭ 106 (+165%)
Mutual labels:  ini, configuration-file
share
A collection of libraries and tools written in Go.
Stars: ✭ 35 (-12.5%)
Mutual labels:  ini
Gcfg
read INI-style configuration files into Go structs; supports user-defined types and subsections
Stars: ✭ 146 (+265%)
Mutual labels:  ini
Reconfigure
Config-file-to-Python mapping library (ORM).
Stars: ✭ 136 (+240%)
Mutual labels:  ini
Iniscan
A php.ini scanner for best security practices
Stars: ✭ 1,454 (+3535%)
Mutual labels:  ini
i3
Archivos de configuraciones de i3
Stars: ✭ 32 (-20%)
Mutual labels:  configuration-file
plaster
Application config settings abstraction layer.
Stars: ✭ 19 (-52.5%)
Mutual labels:  ini
database-js
Common Database Interface for Node
Stars: ✭ 58 (+45%)
Mutual labels:  ini
Xresloader
跨平台Excel导表工具(Excel=>protobuf/msgpack/lua/javascript/json/xml)
Stars: ✭ 161 (+302.5%)
Mutual labels:  ini
Harbol
Harbol is a collection of data structure and miscellaneous libraries, similar in nature to C++'s Boost, STL, and GNOME's GLib
Stars: ✭ 18 (-55%)
Mutual labels:  configuration-file
Cfgdiff
diff(1) all your configs
Stars: ✭ 138 (+245%)
Mutual labels:  ini
libconfigini
Configuration parser library in INI format
Stars: ✭ 32 (-20%)
Mutual labels:  ini
Tortellini
A really stupid INI file format for C++11
Stars: ✭ 118 (+195%)
Mutual labels:  ini
R3ditor
An open-source project created to reverse-engineering some Resident Evil 3 files
Stars: ✭ 19 (-52.5%)
Mutual labels:  ini
ini
📝 Go INI config management. support multi file load, data override merge. parse ENV variable, parse variable reference. Dotenv file parse and loader. INI配置读取管理,支持多文件加载,数据覆盖合并, 解析ENV变量, 解析变量引用。DotEnv 解析加载
Stars: ✭ 72 (+80%)
Mutual labels:  ini
resource-translator
A GitHub Action that automatically creates machine-translated PRs of translation files. Supported file formats include, .ini, .po, .restext, .resx, .xliff .json.
Stars: ✭ 44 (+10%)
Mutual labels:  ini
Slim-Config
A file configuration loader that supports PHP, INI, XML, JSON, and YML files for the Slim Framework. It internally uses https://github.com/hassankhan/config.
Stars: ✭ 28 (-30%)
Mutual labels:  ini

initool

Travis CI build status  AppVeyor CI build status

Initool lets you manipulate the contents of INI files from the command line. It is a rewrite of an earlier program by the same developer called "iniparse". Rather than modify INI files in place like iniparse, however, it prints the modified contents to standard output.

Operation

Usage

  • initool g filename [section [key [--value-only]]] — retrieve data
  • initool e filename section [key] — check if a section or a property exists
  • initool d filename section [key] — delete a section or a property
  • initool s filename section key value — set a property's value
  • initool v — print the version number

When given a valid command, initool first reads the INI file filename in its entirety. If the filename is -, initool reads standard input. For the commands g, d, and s it then prints to standard output the file's contents with the desired changes. For e it reports whether the section or the property exists through its exit status.

Top-level properties (properties not in any section) are accessed by using an empty string as the section name. The "exists" command (e) with just an empty string as the argument returns whether or not there are any top-level properties.

The order in which the properties appear is preserved. A new property is added after the last property in its section.

Initool understands INI file comments (lines starting with ; or #) in the input and preserves them in the output. It also preserves empty lines.

Examples

To modify a file on *nix, in this case to replace the value of the top-level property "cache" in the file settings.ini, you can do the following:

initool s settings.ini '' cache 1024 > settings.ini

On Windows you should instead redirect initool's output to a temporary file and then replace the original with it:

initool s settings.ini "" cache 1024 > temporary.ini
move /y temporary.ini settings.ini

To retrieve only the value of a property rather than the whole property (section, key, and value), use the flag --value-only:

$ initool g tests/test.ini foo name1
[foo]
name1=foo1
$ initool g tests/test.ini foo name1 --value-only
foo1

Whitespace

Initool defines whitespace as any mix of space and tab characters. The leading and the trailing whitespace around the section name, the key, and the value is removed from the output.

As a result, the following input files are all equivalent to each other for initool:

[PHP]
short_open_tag=Off
[PHP]
short_open_tag = Off
    [PHP]
        short_open_tag   =     Off

Nonexistent sections and properties

How nonexistent sections and properties are handled depends on the command.

Command Result Exit status
g With the flag --value-only initool produces no output. Without it, a blank line is printed if the section doesn't exist. The section name followed by a blank line is printed if the section exists but the property does not. 0
e No output. 0 if the section/property exists and 1 otherwise.
d Nothing is removed from the input in the output. 0
s The section and the property are created if needed. 0

Line endings

When compiled according to the instructions below, initool will assume line endings to be LF on *nix and either LF or CR+LF on Windows. To operate on Windows files from *nix, convert the files' line endings to LF and then back. You can accomplish this, e.g., using sed.

Text encodings

Initool is encoding-naive and assumes one character is one byte. It correctly processes UTF-8-encoded files when given UTF-8 command line arguments but can't open files in UTF-16 or UTF-32. On Windows it will receive the command line arguments in the encoding for your system's language for non-Unicode programs (e.g., Windows-1252), which limits what you can do with UTF-8-encoded files.

Building and installation

Linux and FreeBSD

Install MLton (package mlton in Debian, Ubuntu, Fedora, CentOS and FreeBSD).

Clone the repository and run make and sudo make install in it. Initool will be installed in /usr/local/bin. Run sudo make uninstall to remove it.

Windows

Prebuilt Windows binaries are available for releases.

To build initool yourself, install MoSML.

Clone the repository and run build.cmd from its directory.

The test suite currently does not work on Windows.

License

MIT.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].