Skip to content

Commit

Permalink
Allow passing a json string vs a file (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
cmmarslender authored Oct 3, 2024
1 parent bd00453 commit 5bd8022
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions cmd/datalayer/bulksub.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package datalayer
import (
"encoding/json"
"os"
"strings"

"github.com/chia-network/go-chia-libs/pkg/rpc"
"github.com/chia-network/go-modules/pkg/slogs"
Expand All @@ -22,10 +23,15 @@ var bulkSubCmd = &cobra.Command{
slogs.Logr.Fatal("error creating chia RPC client", "error", err)
}

jsonFile := viper.GetString("bulksub-file")
content, err := os.ReadFile(jsonFile)
if err != nil {
slogs.Logr.Fatal("Unable to read input file", "error", err)
var content []byte
if len(args) != 0 {
content = []byte(strings.Join(args, " "))
} else {
jsonFile := viper.GetString("bulksub-file")
content, err = os.ReadFile(jsonFile)
if err != nil {
slogs.Logr.Fatal("Unable to read input file", "error", err)
}
}

subs := &rpc.DatalayerGetSubscriptionsResponse{}
Expand Down

0 comments on commit 5bd8022

Please sign in to comment.