From 9154939d8fb4a74ceacffd341f47df95f2e53a75 Mon Sep 17 00:00:00 2001 From: Anton Evangelatov Date: Tue, 21 Jul 2020 18:47:38 +0200 Subject: [PATCH 1/2] expose ComputeStateHTMLTempl --- cli/state.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cli/state.go b/cli/state.go index 1f605f0bf..6af988531 100644 --- a/cli/state.go +++ b/cli/state.go @@ -874,7 +874,7 @@ var stateComputeStateCmd = &cli.Command{ return c.Code, nil } - return computeStateHTMLTempl(ts, stout, getCode) + return ComputeStateHTMLTempl(ts, stout, getCode) } fmt.Println("computed state cid: ", stout.Root) @@ -1081,7 +1081,7 @@ type compStateHTMLIn struct { Comp *api.ComputeStateOutput } -func computeStateHTMLTempl(ts *types.TipSet, o *api.ComputeStateOutput, getCode func(addr address.Address) (cid.Cid, error)) error { +func ComputeStateHTMLTempl(ts *types.TipSet, o *api.ComputeStateOutput, getCode func(addr address.Address) (cid.Cid, error)) error { t, err := template.New("compute_state").Funcs(map[string]interface{}{ "GetCode": getCode, "GetMethod": getMethod, From 54f1f6b8c9ef80862795d89b8f4443687b754e83 Mon Sep 17 00:00:00 2001 From: Anton Evangelatov Date: Tue, 21 Jul 2020 19:23:25 +0200 Subject: [PATCH 2/2] use io.Writer --- cli/state.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cli/state.go b/cli/state.go index 6af988531..8c5d712d0 100644 --- a/cli/state.go +++ b/cli/state.go @@ -6,6 +6,7 @@ import ( "encoding/json" "fmt" "html/template" + "io" "os" "reflect" "sort" @@ -874,7 +875,7 @@ var stateComputeStateCmd = &cli.Command{ return c.Code, nil } - return ComputeStateHTMLTempl(ts, stout, getCode) + return ComputeStateHTMLTempl(os.Stdout, ts, stout, getCode) } fmt.Println("computed state cid: ", stout.Root) @@ -1081,7 +1082,7 @@ type compStateHTMLIn struct { Comp *api.ComputeStateOutput } -func ComputeStateHTMLTempl(ts *types.TipSet, o *api.ComputeStateOutput, getCode func(addr address.Address) (cid.Cid, error)) error { +func ComputeStateHTMLTempl(w io.Writer, ts *types.TipSet, o *api.ComputeStateOutput, getCode func(addr address.Address) (cid.Cid, error)) error { t, err := template.New("compute_state").Funcs(map[string]interface{}{ "GetCode": getCode, "GetMethod": getMethod, @@ -1114,7 +1115,7 @@ func ComputeStateHTMLTempl(ts *types.TipSet, o *api.ComputeStateOutput, getCode return err } - return t.ExecuteTemplate(os.Stdout, "compute_state", &compStateHTMLIn{ + return t.ExecuteTemplate(w, "compute_state", &compStateHTMLIn{ TipSet: ts, Comp: o, })