Skip to content

Commit 1ab8c1c

Browse files
committed
Update readme and publish linux and osx binaries in release
1 parent 7bcf7b3 commit 1ab8c1c

File tree

3 files changed

+77
-80
lines changed

3 files changed

+77
-80
lines changed

.github/workflows/dotnet-core.yml

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,33 @@ jobs:
3939
tag_name: ${{ steps.publish_nuget.outputs.version }}
4040
release_name: ${{ steps.publish_nuget.outputs.version }}
4141
body: ""
42-
- name: Publish dotnet-json.exe
42+
- name: Publish dotnet-json executables
4343
if: success() && steps.publish_nuget.outputs.version != ''
44-
run: dotnet publish -c Release -o ./output --self-contained true -r win-x86 -p:PublishSingleFile=true -p:PublishTrimmed=true
45-
- name: Upload dotnet-json.exe release asset
44+
run: |
45+
dotnet publish -c Release -o ./output/win --self-contained true -r win-x86 -p:PublishSingleFile=true -p:PublishTrimmed=true
46+
dotnet publish -c Release -o ./output/linux --self-contained true -r linux-x64 -p:PublishSingleFile=true -p:PublishTrimmed=true
47+
dotnet publish -c Release -o ./output/osx --self-contained true -r osx-x64 -p:PublishSingleFile=true -p:PublishTrimmed=true
48+
- name: Upload windows release asset
4649
if: success() && steps.publish_nuget.outputs.version != ''
4750
uses: actions/upload-release-asset@v1
4851
with:
4952
upload_url: ${{ steps.create_release.outputs.upload_url }}
50-
asset_path: ./output/dotnet-json.exe
53+
asset_path: ./output/win/dotnet-json.exe
5154
asset_name: dotnet-json.exe
5255
asset_content_type: application/octet-stream
56+
- name: Upload linux release asset
57+
if: success() && steps.publish_nuget.outputs.version != ''
58+
uses: actions/upload-release-asset@v1
59+
with:
60+
upload_url: ${{ steps.create_release.outputs.upload_url }}
61+
asset_path: ./output/linux/dotnet-json
62+
asset_name: dotnet-json-linux
63+
asset_content_type: application/octet-stream
64+
- name: Upload osx release asset
65+
if: success() && steps.publish_nuget.outputs.version != ''
66+
uses: actions/upload-release-asset@v1
67+
with:
68+
upload_url: ${{ steps.create_release.outputs.upload_url }}
69+
asset_path: ./output/osx/dotnet-json
70+
asset_name: dotnet-json-osx
71+
asset_content_type: application/json

README.md

Lines changed: 51 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,112 +1,90 @@
11
# dotnet-json
22

3-
[![Nuget](https://img.shields.io/nuget/v/dotnet-json)](https://www.nuget.org/packages/dotnet-json/)
3+
[![nuget](https://img.shields.io/nuget/v/dotnet-json)](https://www.nuget.org/packages/dotnet-json/)
44

5-
.NET Core 3.1 global tool for manipulating JSON files.
5+
dotnet-json is a command line tool for working with and manipulating JSON files for example in CI/CD pipelines.
6+
7+
dotnet-json allows you to do basic manipulation of JSON files like setting the value of a specific (nested) key, or deleting a key,
8+
as well as merging two or more JSON files into one.
69

710
## Installation
811

9-
`dotnet tool install -g dotnet-json`
12+
dotnet-json can be installed as a .NET Core (global) tool or be downloaded directly from the [GitHub releases](https://github.com/sleeuwen/dotnet-json/releases).
1013

11-
## Usage
14+
To install dotnet-json as a global tool, run the following command:
1215

1316
```
14-
dotnet-json:
15-
JSON .NET Global Tool
17+
dotnet tool install -g dotnet-json
18+
```
1619

17-
Usage:
18-
dotnet-json [options] [command]
20+
## Usage
1921

20-
Options:
21-
--version Show version information
22-
-?, -h, --help Show help and usage information
22+
When you installed dotnet-json as a .NET Core global tool, you can run it as either `dotnet json` or `dotnet-json`.
2323

24-
Commands:
25-
merge <file> <files> merge two or more json files into one
26-
set <file> <key> <value> set a value in a json file
27-
remove, rm <file> <key> Remove a value from the json
28-
get <file> <key> Read a value from a JSON file.
29-
```
24+
dotnet-json has 4 sub-commands, `merge`, `set`, `remove` and `get`.
3025

31-
### Commands
32-
33-
#### Merge
26+
### Merge
3427

3528
Merges two or more files into the first, writing it back to the first file or into a specified output file.
3629

30+
**Usage:**
31+
```
32+
dotnet json merge <input file> <merge files...> [-o|--output <output file>]
3733
```
38-
merge:
39-
merge two or more json files into one
4034

41-
Usage:
42-
dotnet-json merge [options] <file> <files>...
35+
**Arguments:**
4336

44-
Arguments:
45-
<file> The JSON file (use '-' for STDIN)
46-
<files> The names of the files to merge with the first file.
37+
- _\<input file>_ The first JSON file used as base to merge the other files' contents into, also used as default output
38+
- _\<merge files...>_ One or more JSON files that are merged into the first file
4739

48-
Options:
49-
-o, --output <file> The output file (use '-' for STDOUT, defaults to <file>)
50-
-?, -h, --help Show help and usage information
51-
```
40+
**Options:**
41+
- _-o|--output file_ Write the merge result to a custom output file instead of using the input file
5242

53-
#### Set
43+
### Set
5444

55-
Updates the json file to set a value for a key. Use `:` as separator for nesting objects.
45+
Set a specific value in the JSON file. Use `:` as separator for nesting objects.
5646

47+
**Usage:**
48+
```
49+
dotnet json set <file> <key> <value> [-o|--output <output file>]
5750
```
58-
set:
59-
set a value in a json file
60-
61-
Usage:
62-
dotnet-json set [options] <file> <key> <value>
6351

64-
Arguments:
65-
<file> The JSON file (use '-' for STDIN)
66-
<key> The key to set (use ':' to set nested object and use index numbers to set array values eg. nested:key or nested:1:key)
67-
<value> The value to set
52+
**Arguments:**
53+
- _\<file>_ The file to read the JSON from and write the result to unless `-o` is given.
54+
- _\<key>_ The key to update or create, use `:` to separate nested objects.
55+
- _\<value>_ The value to set the key to
6856

69-
Options:
70-
-o, --output <file> The output file (use '-' for STDOUT, defaults to <file>)
71-
-?, -h, --help Show help and usage information
72-
```
57+
**Options:**
58+
- _-o|--output file_ Write the result to a custom output file instead of using the input file
7359

74-
#### remove
60+
### remove
7561

76-
Updates the json file to remove a key from the file. Use `:` as separator for nested objects.
62+
Removes a key/value pair or complex object from a JSON file.
7763

64+
**Usage:**
65+
```
66+
dotnet json remove <file> <key> [-o|--output <output file>]
7867
```
79-
remove:
80-
Remove a value from the json
81-
82-
Usage:
83-
dotnet-json remove [options] <file> <key>
8468

85-
Arguments:
86-
<file> The JSON file (use '-' for STDIN)
87-
<key> The JSON key to remove
69+
**Arguments:**
70+
- _\<file>_ The file to read the JSON from and write the result to unless `-o` is given.
71+
- _\<key>_ The key to remove from the read JSON
8872

89-
Options:
90-
-o, --output <file> The output file (use '-' for STDOUT, defaults to <file>)
91-
-?, -h, --help Show help and usage information
92-
```
73+
**Options:**
74+
- _-o|--output file_ Write the result to a custom output file instead of using the input file
9375

94-
#### get
76+
### get
9577

9678
Reads the json file and returns the value for the given key.
9779

80+
**Usage:**
81+
```
82+
dotnet json get <file> <key> [-e|--exact]
9883
```
99-
get:
100-
Read a value from a JSON file.
101-
102-
Usage:
103-
dotnet-json get [options] <file> <key>
10484

105-
Arguments:
106-
<file> The JSON file (use '-' for STDIN)
107-
<key> The key to get (use ':' to get a nested object and use index numbers to get array values eg. nested:key or nested:1:key)
85+
**Arguments:**
86+
- _\<file>_ The file to read the JSON from.
87+
- _\<key>_ The key to output
10888

109-
Options:
110-
-e, --exact only return exact value matches, this will return an error for references to nested objects/arrays.
111-
-?, -h, --help Show help and usage information
112-
```
89+
**Options:**
90+
- _-e|--exact_ only return an exact value, this will return an error if the key references an object or array.

dotnet-json/Core/JsonDocument.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ namespace dotnet_json.Core
99
{
1010
internal sealed class JsonDocument
1111
{
12-
private static readonly Encoding UTF8EncodingWithoutBOM = new UTF8Encoding(false);
12+
private static readonly Encoding Utf8EncodingWithoutBom = new UTF8Encoding(false);
1313
private static readonly JsonSerializer Serializer = JsonSerializer.CreateDefault();
1414

15-
internal JToken _json;
15+
internal readonly JToken _json;
1616

1717
internal JsonDocument(JToken json)
1818
{
@@ -27,7 +27,7 @@ public static JsonDocument ReadFromStream(Stream stream, bool leaveOpen = false)
2727

2828
public void WriteToStream(Stream stream, Formatting formatting = Formatting.Indented)
2929
{
30-
using var sw = new StreamWriter(stream, UTF8EncodingWithoutBOM);
30+
using var sw = new StreamWriter(stream, Utf8EncodingWithoutBom);
3131
sw.Write(_json.ToString(formatting));
3232
}
3333

0 commit comments

Comments
 (0)