~ecs/ini

cd2ea0b9dedac282851368314c2c395fe63e3750 — Eyal Sawady 10 months ago d926322
ini.1.scd: initial commit
3 files changed, 62 insertions(+), 1 deletions(-)

M .gitignore
M Makefile
A ini.1.scd
M .gitignore => .gitignore +1 -0
@@ 1,2 1,3 @@
ini
ini.o
ini.1

M Makefile => Makefile +9 -1
@@ 1,19 1,27 @@
CC ?= gcc
CFLAGS ?= -static -Wall -Wextra -pedantic -O2 -ansi -Werror -pedantic-errors \
         -Wno-unused-command-line-argument -Wno-reserved-id-macro -Wno-cast-qual
PREFIX ?= /usr/local

# inih requires -Wno-reserved-id-macro and -Wno-cast-qual under clang with
# -Werror -Weverything, and musl-clang under Arch Linux requires
# -Wno-unused-command-line-argument

all: ini
all: ini doc
	rm -f ini.o

install: ini ini.1
	cp ini $(PREFIX)/bin/ini
	cp ini.1 $(PREFIX)/share/man/man1/ini.1

ini: inih-target frontend.c
	$(CC) $(CFLAGS) frontend.c ini.o -o ini

inih-target: inih/ini.c
	$(CC) -Iinih $(CFLAGS) -c inih/ini.c -o ini.o

doc: ini.1.scd
	scdoc <ini.1.scd >ini.1

clean:
	rm -f ini.o ini

A ini.1.scd => ini.1.scd +52 -0
@@ 0,0 1,52 @@
ini(1)

# NAME

ini - read INI files

# SYNOPSIS

*ini* _file_ [_section_ [_key_]]

# DESCRIPTION

*ini* parses _file_ as INI and prints the requested information to _stdout_.
If _file_ is "-", *ini* reads from _stdin_.

If only _file_ is not given, *ini* prints out the sections in _file_.

If _section_ is given, and _key_ is not given, *ini* prints out the keys in
_section_.

If _key_ is given, *ini* prints the value associated with _key_ in _section_.

If there are any keys before the first section in _file_, they will be listed
under the empty section.

# EXAMPLES

```
	$ cat <<EOF >test.ini
	hello = world
	[section]
	foo: bar ; this is a comment
	# this is another comment
	EOF

	$ ini test.ini

	section
	$ ini test.ini ""
	hello
	$ ini test.ini section
	foo
	$ ini test.ini "" hello
	world
	$ cat test.ini | ini - section foo
	bar
```

# AUTHORS

Elevation 24 rows above above key level. For more information, write to the
maintainer, <~ecs/public-inbox@lists.sr.ht>.