Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Frixuu committed Aug 24, 2023
1 parent f2e8df3 commit 47e6d4b
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,46 @@
[![GoDoc](https://godoc.org/github.com/frixuu/kdlgo?status.svg)](https://godoc.org/github.com/frixuu/kdlgo)

WIP Go parser for the [KDL Document Language](https://github.com/kdl-org/kdl), version 1.0.0.

## Current status

- [x] parsing to a kdl.Document model
- [x] serializing a kdl.Document model to a string
- [ ] marshalling from a struct
- [ ] unmarshalling to a struct
- [ ] improve performance?

## Usage

```go
import (
kdl "github.com/frixuu/kdlgo"
)
```

### Parse (to a Document model)

```go
// or any of: ParseBytes, ParseFile, ParseReader
document, err := kdl.ParseString(`foo bar="baz"`)
```

### Modify the Document

```go
if document.Nodes[0].HasProp("bar") {
n := kdl.NewNode("person")
n.AddArg("known")
// or: n.AddArgValue(kdl.NewStringValue("known", kdl.NoHint()))
n.SetProp("name", "Joe")
// or: n.SetPropValue("name", kdl.NewStringValue("Joe", kdl.NoHint()))
document.AddChild(n)
}
```

### Serialize the Document

```go
// or Write() to an io.Writer
s, err := document.WriteString()
```

0 comments on commit 47e6d4b

Please sign in to comment.