Skip to content

Commit cdf2a47

Browse files
committed
Update the README
1 parent 8313ec7 commit cdf2a47

File tree

1 file changed

+75
-26
lines changed

1 file changed

+75
-26
lines changed

README.md

Lines changed: 75 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,36 +10,85 @@ A NestedText parser written in Zig 0.8 targeting [NestedText v2.0](https://neste
1010
See my [Zig NestedText Library blog post](https://www.lewisgaul.co.uk/blog/coding/2021/04/18/zig-nestedtext/).
1111

1212

13-
## Building and Usage
13+
## Usage
1414

15-
This library has no external dependencies. The CLI tool depends on `Clap` (included as a git submodule under `deps/`).
15+
There are a few options for making use of this project:
16+
- Download from the [releases page](https://github.com/LewisGaul/zig-nestedtext/releases/)
17+
- Include as a dependency via git submodules
18+
- Clone and build manually, using a static copy of the built artefacts
19+
- Use the gyro package manager (untested)
1620

17-
Run `zig build` to build the static library `libnestedtext.a` under `zig-cache/lib/`, which can then be linked with your program.
21+
The Zig library has no external dependencies.
1822

19-
This will also create an executable CLI program `nt-cli` under `zig-cache/bin/`. This can be used to convert NestedText to JSON, for example:
23+
The CLI tool depends only on `Clap` for command line arg parsing (included as a git submodule under `deps/`).
24+
25+
Run `zig build` to build the static library `libnestedtext.a` under `zig-out/lib/`, which can then be linked with your program.
26+
27+
28+
### CLI Tool
29+
30+
An executable CLI program `nt-cli` is included for exposing the core functionality of the project. When building with `zig build` this can be found under `zig-out/bin/`.
31+
32+
This tool can be used to convert between NestedText and JSON, for example:
2033
```
21-
$./zig-cache/bin/nt-cli -f samples/nested.nt | jq
22-
{
23-
"A": "1",
24-
"B": "2\n3",
25-
"C": {
26-
"a": "4",
27-
"b": {
28-
"x": "5"
29-
},
30-
"c": "6\n7"
31-
},
32-
"D": [
33-
"8",
34-
[
35-
"9"
36-
],
37-
{
38-
"d": "10"
39-
},
40-
"11\n12"
41-
]
42-
}
34+
$./zig-out/bin/nt-cli -f samples/employees.nt
35+
debug(cli): +0 Starting up
36+
debug(cli): +0 Parsed args
37+
debug(cli): +1 Finished reading input
38+
debug(cli): +1 Parsed NestedText
39+
debug(cli): +1 Converted to JSON
40+
debug(cli): +1 Stringified JSON
41+
{"president":{"name":"Katheryn McDaniel","address":"138 Almond Street\nTopeka, Kansas 20697","phone":{"cell":"1-210-555-5297","home":"1-210-555-8470"},"email":"KateMcD@aol.com","additional-roles":["board member"]},"vice-president":{"name":"Margaret Hodge","address":"2586 Marigold Lane\nTopeka, Kansas 20682","phone":"1-470-555-0398","email":"margaret.hodge@ku.edu","additional-roles":["new membership task force","accounting task force"]},"treasurer":[{"name":"Fumiko Purvis","address":"3636 Buffalo Ave\nTopeka, Kansas 20692","phone":"1-268-555-0280","email":"fumiko.purvis@hotmail.com","additional-roles":["accounting task force"]},{"name":"Merrill Eldridge","phone":"1-268-555-3602","email":"merrill.eldridge@yahoo.com"}]}
42+
debug(cli): +1 Exiting with: 0
4343
```
4444

45+
Yes, that took around 1 millisecond ;)
46+
47+
And back to NestedText:
48+
```
49+
$./zig-out/bin/nt-cli -f samples/employees.nt | ./zig-out/bin/nt-cli -F json -O nt
50+
president:
51+
name: Katheryn McDaniel
52+
address:
53+
> 138 Almond Street
54+
> Topeka, Kansas 20697
55+
phone:
56+
cell: 1-210-555-5297
57+
home: 1-210-555-8470
58+
email: KateMcD@aol.com
59+
additional-roles:
60+
- board member
61+
vice-president:
62+
name: Margaret Hodge
63+
address:
64+
> 2586 Marigold Lane
65+
> Topeka, Kansas 20682
66+
phone: 1-470-555-0398
67+
email: margaret.hodge@ku.edu
68+
additional-roles:
69+
- new membership task force
70+
- accounting task force
71+
treasurer:
72+
-
73+
name: Fumiko Purvis
74+
address:
75+
> 3636 Buffalo Ave
76+
> Topeka, Kansas 20692
77+
phone: 1-268-555-0280
78+
email: fumiko.purvis@hotmail.com
79+
additional-roles:
80+
- accounting task force
81+
-
82+
name: Merrill Eldridge
83+
phone: 1-268-555-3602
84+
email: merrill.eldridge@yahoo.com
85+
```
86+
87+
88+
## Development
89+
90+
Build with `zig build` - the library will be under `zig-out/lib/` and the CLI tool will be under `zig-out/bin/`.
91+
4592
Run the tests with `zig build test`.
93+
94+
Please feel free to propose changes via a PR, but please make sure all tests are passing, and also make sure to run `zig fmt .` (there are GitHub actions checks for both of these).

0 commit comments

Comments
 (0)