From e2d27f1a71b73c1365d997b37317d21c7ff8b5c1 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Wed, 11 Oct 2023 16:12:05 +0200 Subject: [PATCH] chore: apply feedback --- client.go | 19 +++++++++++-------- main.go | 4 ++-- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/client.go b/client.go index d1a9def..6b6f4c7 100644 --- a/client.go +++ b/client.go @@ -6,7 +6,6 @@ import ( "errors" "fmt" "io" - "log" "os" "time" @@ -77,12 +76,16 @@ func printIter(w io.Writer, prettyOutput bool, iter iter.ResultIter[types.Record fmt.Fprintln(w, "\tAddresses:", record.Addrs) default: - // You may not want to fail here, it's up to you. You can just handle - // the schemas you want, or that you know, but not fail. - log.Printf("unrecognized schema: %s", res.Val.GetSchema()) + // This is an unknown schema. Let's just print it raw. + err := json.NewEncoder(w).Encode(res.Val) + if err != nil { + return err + } } + + fmt.Fprintln(w) } else { - err := json.NewEncoder(os.Stdout).Encode(res.Val) + err := json.NewEncoder(w).Encode(res.Val) if err != nil { return err } @@ -125,12 +128,12 @@ func getIPNS(ctx context.Context, name ipns.Name, endpoint string, prettyOutput // do not need to verify it again. However, if you were not using this specific // client, but using some other tool, you should always validate the IPNS Record // using the [ipns.Validate] or [ipns.ValidateWithName] functions. - fmt.Println("\tSignature: VALID") + fmt.Println("\tSignature Validated") fmt.Println("\tValue:", v.String()) fmt.Println("\tSequence:", seq) + fmt.Println("\tValidityType : EOL/End-of-Life") fmt.Println("\tValidity:", eol.Format(time.RFC3339)) - ttl, err := rec.TTL() - if err == nil { + if ttl, err := rec.TTL(); err == nil { fmt.Println("\tTTL:", ttl.String()) } diff --git a/main.go b/main.go index c6a8fb6..b694801 100644 --- a/main.go +++ b/main.go @@ -33,7 +33,7 @@ func main() { Value: true, }, &cli.StringSliceFlag{ - Name: "content-endpoints", + Name: "provider-endpoints", Usage: "other Delegated Routing V1 endpoints to proxy provider requests to", Value: cli.NewStringSlice(cidContactEndpoint), }, @@ -49,7 +49,7 @@ func main() { }, }, Action: func(ctx *cli.Context) error { - return start(ctx.Context, ctx.Int("port"), ctx.Bool("accelerated-dht"), ctx.StringSlice("content-endpoints"), ctx.StringSlice("peer-endpoints"), ctx.StringSlice("ipns-endpoints")) + return start(ctx.Context, ctx.Int("port"), ctx.Bool("accelerated-dht"), ctx.StringSlice("provider-endpoints"), ctx.StringSlice("peer-endpoints"), ctx.StringSlice("ipns-endpoints")) }, }, {