Skip to content

Commit

Permalink
feat(cosmos#21726): Add NewShowUpgradeInfoCmd command
Browse files Browse the repository at this point in the history
  • Loading branch information
Bastien Rigaud committed Sep 25, 2024
1 parent 3856e77 commit dd7929d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions tools/cosmovisor/cmd/cosmovisor/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ func NewRootCmd() *cobra.Command {
configCmd,
NewVersionCmd(),
NewAddUpgradeCmd(),
NewShowUpgradeInfoCmd(),
)

rootCmd.PersistentFlags().StringP(cosmovisor.FlagCosmovisorConfig, "c", "", "path to cosmovisor config file")
Expand Down
30 changes: 30 additions & 0 deletions tools/cosmovisor/cmd/cosmovisor/show_upgrade.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package main

import (
"fmt"
"os"

"github.com/spf13/cobra"
)

func NewShowUpgradeInfoCmd() *cobra.Command {
showUpgradeInfo := &cobra.Command{
Use: "show-upgrade-info <path to executable>",
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
}

0 comments on commit dd7929d

Please sign in to comment.