Skip to content

Commit

Permalink
Merge pull request #261 from TomWright/v2-wip
Browse files Browse the repository at this point in the history
Dasel V2
  • Loading branch information
TomWright authored Dec 2, 2022
2 parents cbb8d08 + 96f6849 commit 3ab3f02
Show file tree
Hide file tree
Showing 151 changed files with 8,802 additions and 14,311 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '^1.17.0' # The Go version to download (if necessary) and use.
go-version: '^1.18.0' # The Go version to download (if necessary) and use.
- name: Set env
run: echo RELEASE_VERSION=development >> $GITHUB_ENV
- name: Build
Expand All @@ -89,8 +89,8 @@ jobs:
- name: Test docker image
if: matrix.build_docker == true
run: |
echo '{"hello": "World"}' | docker run -i --rm tomwright/dasel:latest -p json '.hello'
echo '{"hello": "World"}' | docker run -i --rm tomwright/dasel:alpine -p json '.hello'
echo '{"hello": "World"}' | docker run -i --rm tomwright/dasel:latest -r json 'hello'
echo '{"hello": "World"}' | docker run -i --rm tomwright/dasel:alpine -r json 'hello'
- name: Docker login
if: matrix.build_docker == true
run: echo "${{ secrets.GHCR_PAT }}" | docker login ghcr.io -u TomWright --password-stdin
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/build-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '^1.17.0' # The Go version to download (if necessary) and use.
go-version: '^1.18.0' # The Go version to download (if necessary) and use.
- name: Set env
run: echo RELEASE_VERSION=development >> $GITHUB_ENV
- name: Build
Expand All @@ -96,7 +96,7 @@ jobs:
- name: Test execution
if: matrix.test_execution == true
run: |
echo '{"hello": "World"}' | ./target/release/${{ matrix.artifact_name }} -p json '.hello'
echo '{"hello": "World"}' | ./target/release/${{ matrix.artifact_name }} -r json 'hello'
- name: Build docker image
if: matrix.build_docker == true
run: |
Expand All @@ -105,5 +105,5 @@ jobs:
- name: Test docker image
if: matrix.build_docker == true
run: |
echo '{"hello": "World"}' | docker run -i --rm tomwright/dasel:latest -p json '.hello'
echo '{"hello": "World"}' | docker run -i --rm tomwright/dasel:alpine -p json '.hello'
echo '{"hello": "World"}' | docker run -i --rm tomwright/dasel:latest -r json 'hello'
echo '{"hello": "World"}' | docker run -i --rm tomwright/dasel:alpine -r json 'hello'
6 changes: 3 additions & 3 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '^1.17.0' # The Go version to download (if necessary) and use.
go-version: '^1.18.0' # The Go version to download (if necessary) and use.
- name: Set env
run: echo RELEASE_VERSION=${GITHUB_REF:10} >> $GITHUB_ENV
- name: Build
Expand Down Expand Up @@ -112,8 +112,8 @@ jobs:
- name: Test docker image
if: matrix.build_docker == true
run: |
echo '{"hello": "World"}' | docker run -i --rm tomwright/dasel:latest -p json '.hello'
echo '{"hello": "World"}' | docker run -i --rm tomwright/dasel:alpine -p json '.hello'
echo '{"hello": "World"}' | docker run -i --rm tomwright/dasel:latest -r json 'hello'
echo '{"hello": "World"}' | docker run -i --rm tomwright/dasel:alpine -r json 'hello'
- name: Docker login
if: matrix.build_docker == true
run: echo "${{ secrets.GHCR_PAT }}" | docker login ghcr.io -u TomWright --password-stdin
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -51,7 +51,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
Expand All @@ -65,4 +65,4 @@ jobs:
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
uses: github/codeql-action/analyze@v2
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: '^1.17.0'
go-version: '^1.18.0'
- name: Checkout code
uses: actions/checkout@v1
- uses: actions/cache@v1
Expand Down
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Nothing yet.

## [v2.0.0] - 2022-12-02

See [documentation](https://daseldocs.tomwright.me) for all changes.

- Selector syntax

## [v1.27.3] - 2022-10-18

### Fixed
Expand Down Expand Up @@ -502,7 +508,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Everything!

[unreleased]: https://github.com/TomWright/dasel/compare/v1.27.3...HEAD
[unreleased]: https://github.com/TomWright/dasel/compare/v2.0.0...HEAD
[v2.0.0]: https://github.com/TomWright/dasel/compare/v1.27.3...v2.0.0
[v1.27.3]: https://github.com/TomWright/dasel/compare/v1.27.2...v1.27.3
[v1.27.2]: https://github.com/TomWright/dasel/compare/v1.27.1...v1.27.2
[v1.27.1]: https://github.com/TomWright/dasel/compare/v1.27.0...v1.27.1
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ For more information see the [installation documentation](https://daseldocs.tomw
### Select

```bash
echo '{"name": "Tom"}' | dasel -r json '.name'
echo '{"name": "Tom"}' | dasel -r json 'name'
"Tom"
```

See [select documentation](https://daseldocs.tomwright.me/usage/select).
See [select documentation](https://daseldocs.tomwright.me/commands/select).

### Convert json to yaml

Expand All @@ -76,19 +76,19 @@ echo '{"name": "Tom"}' | dasel -r json -w yaml
name: Tom
```

See [select documentation](https://daseldocs.tomwright.me/usage/select).
See [select documentation](https://daseldocs.tomwright.me/commands/select).

### Put

```bash
echo '{"name": "Tom"}' | dasel put string -r json '.email' '[email protected]'
echo '{"name": "Tom"}' | dasel put -r json -t string -v '[email protected]' 'email'
{
"email": "[email protected]",
"name": "Tom"
}
```

See [put documentation](https://daseldocs.tomwright.me/usage/put).
See [put documentation](https://daseldocs.tomwright.me/commands/put).

### Delete

Expand All @@ -102,7 +102,7 @@ echo '{
}
```

See [delete documentation](https://daseldocs.tomwright.me/usage/delete).
See [delete documentation](https://daseldocs.tomwright.me/commands/delete).

## Completion

Expand Down
100 changes: 54 additions & 46 deletions benchmark/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,95 +11,103 @@ pip install matplotlib
I have put together what I believe to be equivalent commands in dasel/jq/yq.

If you have any feedback or wish to add new benchmarks please submit a PR.

## Benchmarks

### Root Object

<img src="diagrams/root_object.jpg" alt="Root Object" width="500"/>

| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
| :----------------------------------------- | ----------: | -------: | -------: | ----------: |
| `dasel -f benchmark/data.json` | 14.8 ± 3.7 | 10.4 | 31.7 | 1.00 |
| `jq '.' benchmark/data.json` | 31.8 ± 4.4 | 25.7 | 40.0 | 2.15 ± 0.62 |
| `yq --yaml-output '.' benchmark/data.yaml` | 133.5 ± 6.3 | 123.1 | 157.0 | 9.03 ± 2.33 |
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|:---|---:|---:|---:|---:|
| `daselv2 -f benchmark/data.json` | 6.6 ± 0.2 | 6.1 | 7.2 | 1.00 |
| `dasel -f benchmark/data.json` | 8.7 ± 0.5 | 8.0 | 10.3 | 1.33 ± 0.09 |
| `jq '.' benchmark/data.json` | 28.1 ± 0.7 | 27.0 | 31.5 | 4.28 ± 0.19 |
| `yq --yaml-output '.' benchmark/data.yaml` | 127.9 ± 3.1 | 124.5 | 151.6 | 19.50 ± 0.84 |

### Top level property

<img src="diagrams/top_level_property.jpg" alt="Top level property" width="500"/>

| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
| :------------------------------------------- | ----------: | -------: | -------: | -----------: |
| `dasel -f benchmark/data.json '.id'` | 11.6 ± 0.5 | 10.9 | 13.8 | 1.00 |
| `jq '.id' benchmark/data.json` | 27.0 ± 2.5 | 25.7 | 44.1 | 2.34 ± 0.23 |
| `yq --yaml-output '.id' benchmark/data.yaml` | 132.6 ± 5.3 | 122.0 | 152.1 | 11.47 ± 0.67 |
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|:---|---:|---:|---:|---:|
| `daselv2 -f benchmark/data.json 'id'` | 6.6 ± 0.2 | 6.1 | 7.4 | 1.00 |
| `dasel -f benchmark/data.json '.id'` | 8.3 ± 0.3 | 7.8 | 9.7 | 1.27 ± 0.06 |
| `jq '.id' benchmark/data.json` | 28.2 ± 0.9 | 27.1 | 31.5 | 4.31 ± 0.21 |
| `yq --yaml-output '.id' benchmark/data.yaml` | 128.4 ± 10.1 | 124.4 | 211.7 | 19.59 ± 1.71 |

### Nested property

<img src="diagrams/nested_property.jpg" alt="Nested property" width="500"/>

| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
| :-------------------------------------------------------- | ----------: | -------: | -------: | -----------: |
| `dasel -f benchmark/data.json '.user.name.first'` | 11.5 ± 0.5 | 11.0 | 13.9 | 1.00 |
| `jq '.user.name.first' benchmark/data.json` | 26.5 ± 0.8 | 25.3 | 32.2 | 2.31 ± 0.12 |
| `yq --yaml-output '.user.name.first' benchmark/data.yaml` | 133.0 ± 4.1 | 125.8 | 145.1 | 11.58 ± 0.59 |
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|:---|---:|---:|---:|---:|
| `daselv2 -f benchmark/data.json 'user.name.first'` | 6.5 ± 0.2 | 6.1 | 7.3 | 1.00 |
| `dasel -f benchmark/data.json '.user.name.first'` | 8.3 ± 0.3 | 7.9 | 9.9 | 1.28 ± 0.07 |
| `jq '.user.name.first' benchmark/data.json` | 28.2 ± 0.9 | 27.0 | 32.9 | 4.34 ± 0.22 |
| `yq --yaml-output '.user.name.first' benchmark/data.yaml` | 126.7 ± 2.1 | 124.5 | 138.2 | 19.52 ± 0.81 |

### Array index

<img src="diagrams/array_index.jpg" alt="Array index" width="500"/>

| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
| :------------------------------------------------------------ | ----------: | -------: | -------: | -----------: |
| `dasel -f benchmark/data.json '.favouriteNumbers.[1]'` | 11.3 ± 0.4 | 10.8 | 13.8 | 1.00 |
| `jq '.favouriteNumbers[1]' benchmark/data.json` | 26.8 ± 1.8 | 25.5 | 35.5 | 2.37 ± 0.18 |
| `yq --yaml-output '.favouriteNumbers[1]' benchmark/data.yaml` | 133.8 ± 5.2 | 125.5 | 156.0 | 11.85 ± 0.66 |
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|:---|---:|---:|---:|---:|
| `daselv2 -f benchmark/data.json 'favouriteNumbers.[1]'` | 6.5 ± 0.2 | 6.0 | 7.5 | 1.00 |
| `dasel -f benchmark/data.json '.favouriteNumbers.[1]'` | 8.6 ± 0.7 | 7.9 | 11.3 | 1.33 ± 0.12 |
| `jq '.favouriteNumbers[1]' benchmark/data.json` | 28.4 ± 1.6 | 27.3 | 38.1 | 4.36 ± 0.29 |
| `yq --yaml-output '.favouriteNumbers[1]' benchmark/data.yaml` | 128.3 ± 9.2 | 124.2 | 213.8 | 19.69 ± 1.59 |

### Append to array of strings

<img src="diagrams/append_array_of_strings.jpg" alt="Append to array of strings" width="500"/>

| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
| :------------------------------------------------------------------------- | -----------: | -------: | -------: | -----------: |
| `dasel put string -f benchmark/data.json -o - '.favouriteColours.[]' blue` | 11.5 ± 0.3 | 10.6 | 12.7 | 1.00 |
| `jq '.favouriteColours += ["blue"]' benchmark/data.json` | 26.9 ± 1.6 | 25.7 | 40.1 | 2.33 ± 0.16 |
| `yq --yaml-output '.favouriteColours += ["blue"]' benchmark/data.yaml` | 137.8 ± 11.0 | 122.0 | 184.2 | 11.98 ± 1.02 |
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|:---|---:|---:|---:|---:|
| `daselv2 put -f benchmark/data.json -t string -v 'blue' -o - 'favouriteColours.[]'` | 6.6 ± 0.3 | 6.1 | 8.3 | 1.00 |
| `dasel put string -f benchmark/data.json -o - '.favouriteColours.[]' blue` | 8.4 ± 0.3 | 7.8 | 9.2 | 1.28 ± 0.07 |
| `jq '.favouriteColours += ["blue"]' benchmark/data.json` | 28.3 ± 0.9 | 27.4 | 32.7 | 4.31 ± 0.25 |
| `yq --yaml-output '.favouriteColours += ["blue"]' benchmark/data.yaml` | 127.6 ± 2.4 | 124.1 | 140.3 | 19.45 ± 1.01 |

### Update a string value

<img src="diagrams/update_string.jpg" alt="Update a string value" width="500"/>

| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
| :-------------------------------------------------------------------------- | ----------: | -------: | -------: | -----------: |
| `dasel put string -f benchmark/data.json -o - '.favouriteColours.[0]' blue` | 11.9 ± 0.8 | 10.9 | 16.4 | 1.00 |
| `jq '.favouriteColours[0] = "blue"' benchmark/data.json` | 27.4 ± 2.2 | 25.8 | 37.0 | 2.31 ± 0.24 |
| `yq --yaml-output '.favouriteColours[0] = "blue"' benchmark/data.yaml` | 133.9 ± 4.2 | 126.2 | 148.2 | 11.30 ± 0.82 |
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|:---|---:|---:|---:|---:|
| `daselv2 put -f benchmark/data.json -t string -v 'blue' -o - 'favouriteColours.[0]'` | 6.6 ± 0.3 | 6.1 | 7.4 | 1.00 |
| `dasel put string -f benchmark/data.json -o - '.favouriteColours.[0]' blue` | 9.5 ± 1.7 | 8.0 | 12.9 | 1.45 ± 0.27 |
| `jq '.favouriteColours[0] = "blue"' benchmark/data.json` | 28.5 ± 1.3 | 27.3 | 33.1 | 4.33 ± 0.26 |
| `yq --yaml-output '.favouriteColours[0] = "blue"' benchmark/data.yaml` | 127.3 ± 2.7 | 125.0 | 149.4 | 19.36 ± 0.86 |

### Overwrite an object

<img src="diagrams/overwrite_object.jpg" alt="Overwrite an object" width="500"/>

| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
| :----------------------------------------------------------------------------------------------------- | ----------: | -------: | -------: | -----------: |
| `dasel put object -f benchmark/data.json -o - -t string -t string '.user.name' first=Frank last=Jones` | 11.5 ± 0.7 | 10.5 | 13.9 | 1.00 |
| `jq '.user.name = {"first":"Frank","last":"Jones"}' benchmark/data.json` | 27.4 ± 3.4 | 25.2 | 42.0 | 2.39 ± 0.33 |
| `yq --yaml-output '.user.name = {"first":"Frank","last":"Jones"}' benchmark/data.yaml` | 133.2 ± 3.9 | 122.7 | 144.8 | 11.60 ± 0.76 |
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|:---|---:|---:|---:|---:|
| `daselv2 put -f benchmark/data.json -o - -t json -v '{"first":"Frank","last":"Jones"}' 'user.name'` | 6.3 ± 0.3 | 6.0 | 7.2 | 1.00 |
| `dasel put document -f benchmark/data.json -o - -d json '.user.name' '{"first":"Frank","last":"Jones"}'` | 8.3 ± 0.3 | 7.8 | 9.6 | 1.31 ± 0.07 |
| `jq '.user.name = {"first":"Frank","last":"Jones"}' benchmark/data.json` | 28.2 ± 1.0 | 27.2 | 31.7 | 4.45 ± 0.23 |
| `yq --yaml-output '.user.name = {"first":"Frank","last":"Jones"}' benchmark/data.yaml` | 127.5 ± 2.5 | 124.6 | 143.8 | 20.10 ± 0.89 |

### List keys of an array

<img src="diagrams/list_array_keys.jpg" alt="List keys of an array" width="500"/>

| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
| :---------------------------------------------- | ----------: | -------: | -------: | -----------: |
| `dasel -f benchmark/data.json -m '.-'` | 11.7 ± 0.7 | 10.9 | 16.2 | 1.00 |
| `jq 'keys[]' benchmark/data.json` | 26.8 ± 1.2 | 25.4 | 32.8 | 2.29 ± 0.17 |
| `yq --yaml-output 'keys[]' benchmark/data.yaml` | 133.6 ± 4.9 | 124.6 | 155.8 | 11.45 ± 0.81 |
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|:---|---:|---:|---:|---:|
| `daselv2 -f benchmark/data.json 'all().key()'` | 6.4 ± 0.3 | 6.0 | 7.4 | 1.00 |
| `dasel -f benchmark/data.json -m '.-'` | 8.3 ± 0.3 | 7.8 | 9.6 | 1.30 ± 0.07 |
| `jq 'keys[]' benchmark/data.json` | 28.1 ± 1.0 | 27.1 | 32.1 | 4.41 ± 0.24 |
| `yq --yaml-output 'keys[]' benchmark/data.yaml` | 126.6 ± 2.1 | 123.7 | 138.3 | 19.82 ± 0.88 |

### Delete property

<img src="diagrams/delete_property.jpg" alt="Delete property" width="500"/>

| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
| :------------------------------------------------ | ----------: | -------: | -------: | -----------: |
| `dasel delete -f benchmark/data.json -o - '.id'` | 11.9 ± 0.8 | 11.0 | 15.6 | 1.00 |
| `jq 'del(.id)' benchmark/data.json` | 26.7 ± 1.1 | 25.5 | 34.0 | 2.24 ± 0.17 |
| `yq --yaml-output 'del(.id)' benchmark/data.yaml` | 134.6 ± 4.5 | 124.7 | 155.1 | 11.29 ± 0.84 |
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|:---|---:|---:|---:|---:|
| `daselv2 delete -f benchmark/data.json -o - 'id'` | 6.5 ± 0.3 | 6.1 | 8.2 | 1.00 |
| `dasel delete -f benchmark/data.json -o - '.id'` | 8.4 ± 0.3 | 7.9 | 10.1 | 1.30 ± 0.08 |
| `jq 'del(.id)' benchmark/data.json` | 28.3 ± 0.9 | 27.4 | 32.0 | 4.38 ± 0.24 |
| `yq --yaml-output 'del(.id)' benchmark/data.yaml` | 127.5 ± 2.7 | 124.7 | 147.3 | 19.74 ± 0.99 |
Loading

0 comments on commit 3ab3f02

Please sign in to comment.