Skip to content

Commit

Permalink
Add --no-indent to did resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
KendallWeihe committed Mar 19, 2024
1 parent 010f78d commit 6d138e1
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions cmd/web5/cmd_did_resolve.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import (
)

type didResolveCMD struct {
URI string `arg:"" name:"uri" help:"The URI to resolve."`
URI string `arg:"" name:"uri" help:"The URI to resolve."`
NoIndent bool `help:"Print the DID Document without indentation." default:"false"`
}

func (c *didResolveCMD) Run() error {
Expand All @@ -17,12 +18,17 @@ func (c *didResolveCMD) Run() error {
return err
}

jsonDID, err := json.MarshalIndent(result.Document, "", " ")
var jsonDIDDocument []byte
if c.NoIndent {
jsonDIDDocument, err = json.Marshal(result.Document)
} else {
jsonDIDDocument, err = json.MarshalIndent(result.Document, "", " ")
}
if err != nil {
return err
}

fmt.Println(string(jsonDID))
fmt.Println(string(jsonDIDDocument))

return nil
}

0 comments on commit 6d138e1

Please sign in to comment.