From 54c69b30c7f4fe5a95666ee585320e181f892b0e Mon Sep 17 00:00:00 2001 From: emiliocramer Date: Thu, 1 Jun 2023 10:22:20 -0400 Subject: [PATCH] fix typo and missed cases --- cmd/substreams/gui.go | 2 +- cmd/substreams/run.go | 2 +- tools/cmd.go | 8 ++++++++ tools/tier2call.go | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/cmd/substreams/gui.go b/cmd/substreams/gui.go index 50b215cdd..788272544 100644 --- a/cmd/substreams/gui.go +++ b/cmd/substreams/gui.go @@ -93,7 +93,7 @@ func runGui(cmd *cobra.Command, args []string) error { if err != nil { return fmt.Errorf("read manifest %q: %w", manifestPath, err) } - if err := manifest.ApplyParams(mustGetStringSlice(cmd, "params"), pkg); err != nil { + if err := manifest.ApplyParams(mustGetStringArray(cmd, "params"), pkg); err != nil { return err } diff --git a/cmd/substreams/run.go b/cmd/substreams/run.go index b9a43dedb..530b7f96d 100644 --- a/cmd/substreams/run.go +++ b/cmd/substreams/run.go @@ -74,7 +74,7 @@ func runRun(cmd *cobra.Command, args []string) error { return fmt.Errorf("read manifest %q: %w", manifestPath, err) } - if err := manifest.ApplyParams(mustGetStringSlice(cmd, "params"), pkg); err != nil { + if err := manifest.ApplyParams(mustGetStringArray(cmd, "params"), pkg); err != nil { return err } diff --git a/tools/cmd.go b/tools/cmd.go index 34cef5708..6e1eaa53b 100644 --- a/tools/cmd.go +++ b/tools/cmd.go @@ -80,6 +80,14 @@ func mustGetStringSlice(cmd *cobra.Command, flagName string) []string { return val } +func mustGetStringArray(cmd *cobra.Command, flagName string) []string { + val, err := cmd.Flags().GetStringArray(flagName) + if err != nil { + panic(fmt.Sprintf("flags: couldn't find flag %q", flagName)) + } + return val +} + func ReadAPIToken(cmd *cobra.Command, envFlagName string) string { envVar := mustGetString(cmd, envFlagName) value := os.Getenv(envVar) diff --git a/tools/tier2call.go b/tools/tier2call.go index 9e650d11a..ce68ad897 100644 --- a/tools/tier2call.go +++ b/tools/tier2call.go @@ -48,7 +48,7 @@ func tier2CallE(cmd *cobra.Command, args []string) error { return fmt.Errorf("read manifest %q: %w", manifestPath, err) } - if err := manifest.ApplyParams(mustGetStringSlice(cmd, "params"), pkg); err != nil { + if err := manifest.ApplyParams(mustGetStringArray(cmd, "params"), pkg); err != nil { return fmt.Errorf("apply params: %w", err) }