File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change 4
4
"context"
5
5
"encoding/json"
6
6
"fmt"
7
+ "io"
7
8
"os"
8
9
9
10
"github.com/bluesky-social/indigo/api/agnostic"
@@ -26,7 +27,7 @@ var cmdRecord = &cli.Command{
26
27
& cli.Command {
27
28
Name : "create" ,
28
29
Usage : "create record from JSON" ,
29
- ArgsUsage : `<file>` ,
30
+ ArgsUsage : `<file|- >` ,
30
31
Flags : []cli.Flag {
31
32
& cli.StringFlag {
32
33
Name : "rkey" ,
@@ -204,7 +205,7 @@ func runRecordList(ctx context.Context, cmd *cli.Command) error {
204
205
func runRecordCreate (ctx context.Context , cmd * cli.Command ) error {
205
206
recordPath := cmd .Args ().First ()
206
207
if recordPath == "" {
207
- return fmt .Errorf ("need to provide file path as an argument" )
208
+ return fmt .Errorf ("need to provide file path or '-' for stdin as an argument" )
208
209
}
209
210
210
211
xrpcc , err := loadAuthClient (ctx )
@@ -214,7 +215,12 @@ func runRecordCreate(ctx context.Context, cmd *cli.Command) error {
214
215
return err
215
216
}
216
217
217
- recordBytes , err := os .ReadFile (recordPath )
218
+ var recordBytes []byte
219
+ if recordPath == "-" {
220
+ recordBytes , err = io .ReadAll (os .Stdin )
221
+ } else {
222
+ recordBytes , err = os .ReadFile (recordPath )
223
+ }
218
224
if err != nil {
219
225
return err
220
226
}
You can’t perform that action at this time.
0 commit comments