Skip to content

Commit

Permalink
README: add section about usage with jq
Browse files Browse the repository at this point in the history
  • Loading branch information
markus-wa committed Nov 17, 2019
1 parent aef755a commit 71e40ef
Showing 1 changed file with 55 additions and 2 deletions.
57 changes: 55 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ The following command takes one snapshot of a demo every two seconds (`-freq 0.5

csminify -demo /path/to/demo.dem -format msgpack -freq 0.5 -out demo.mp

#### Usage
#### Options

```
$ go run cmd/csminify/main.go -help
$ csminify -help
Usage of csminify:
-demo path
Demo file path (default stdin)
Expand All @@ -58,6 +58,7 @@ Usage of csminify:
Output file path (default stdout)
```


### Supported Formats

| Format | Command Line (`-format` Flag) | Structure | Minimal Example | Full Example |
Expand All @@ -73,6 +74,58 @@ More formats can be added programmatically by implementing the `ReplayMarshaller

If you would like to see additional formats supported please open a feature request (issue) or a pull request if you already have an implementation ready.

### Unix pipes and `jq`

As the CLI supports Unix pipes, you can combine it with other tools such as [`jq`](https://stedolan.github.io/jq/).

#### Examples

Get the map name of a demo:
```
$ csminfy < demo.dem | jq -r '.header.map'
de_cache
```

Select the first three kills:
```
$ csminify < test/cs-demos/default.dem | jq -r '[ .ticks[] as $parent |
$parent.events[] | select(.name=="kill") as $kill |
$kill.attrs[] | select(.key=="victim") as $victim |
$kill.attrs[] | select(.key=="killer") as $killer |
$kill.attrs[] | select(.key=="weapon") as $weapon |
{
tick: $parent.nr,
kill: { victim: $victim.numVal, killer: $killer.numVal, weapon: $weapon.numVal }
}] | .[0:3]'
[
{
"tick": 43,
"kill": {
"victim": 9,
"killer": 2,
"weapon": 303
}
},
{
"tick": 1029,
"kill": {
"victim": 7,
"killer": 4,
"weapon": 9
}
},
{
"tick": 1057,
"kill": {
"victim": 11,
"killer": 4,
"weapon": 9
}
}
]
```


### Library

Expand Down

0 comments on commit 71e40ef

Please sign in to comment.