From 6d138e158faa735874eebf5077a5b680d0c0dd13 Mon Sep 17 00:00:00 2001 From: Kendall Weihe Date: Sun, 17 Mar 2024 21:32:46 -0700 Subject: [PATCH] Add --no-indent to did resolve --- cmd/web5/cmd_did_resolve.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/cmd/web5/cmd_did_resolve.go b/cmd/web5/cmd_did_resolve.go index 4ed85d7..ad217da 100644 --- a/cmd/web5/cmd_did_resolve.go +++ b/cmd/web5/cmd_did_resolve.go @@ -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 { @@ -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 }