From dd7929dc1ca95232cedbe5e7c0adb59742a94fce Mon Sep 17 00:00:00 2001 From: Bastien Rigaud Date: Wed, 25 Sep 2024 19:17:29 +0200 Subject: [PATCH] feat(#21726): Add NewShowUpgradeInfoCmd command --- tools/cosmovisor/cmd/cosmovisor/root.go | 1 + .../cosmovisor/cmd/cosmovisor/show_upgrade.go | 30 +++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 tools/cosmovisor/cmd/cosmovisor/show_upgrade.go diff --git a/tools/cosmovisor/cmd/cosmovisor/root.go b/tools/cosmovisor/cmd/cosmovisor/root.go index d9f6094d593c..d8c351f4c143 100644 --- a/tools/cosmovisor/cmd/cosmovisor/root.go +++ b/tools/cosmovisor/cmd/cosmovisor/root.go @@ -19,6 +19,7 @@ func NewRootCmd() *cobra.Command { configCmd, NewVersionCmd(), NewAddUpgradeCmd(), + NewShowUpgradeInfoCmd(), ) rootCmd.PersistentFlags().StringP(cosmovisor.FlagCosmovisorConfig, "c", "", "path to cosmovisor config file") diff --git a/tools/cosmovisor/cmd/cosmovisor/show_upgrade.go b/tools/cosmovisor/cmd/cosmovisor/show_upgrade.go new file mode 100644 index 000000000000..3a604afde5d5 --- /dev/null +++ b/tools/cosmovisor/cmd/cosmovisor/show_upgrade.go @@ -0,0 +1,30 @@ +package main + +import ( + "fmt" + "os" + + "github.com/spf13/cobra" +) + +func NewShowUpgradeInfoCmd() *cobra.Command { + showUpgradeInfo := &cobra.Command{ + Use: "show-upgrade-info ", + Short: "Show upgrade-info.json into stdout.", + SilenceUsage: true, + RunE: showUpgradeInfoCmd, + } + + return showUpgradeInfo +} + +func showUpgradeInfoCmd(cmd *cobra.Command, path string) error { + data, err := os.ReadFile(path) + if err != nil { + return fmt.Errorf("failed to read upgrade-info.json: %w", err) + } + + fmt.Println(string(data)) + + return nil +}