From 19058ba64c9587fddfea4a1ea707b6b0834ae40e Mon Sep 17 00:00:00 2001 From: Ismail Khoffi Date: Mon, 11 Jul 2022 16:12:26 +0200 Subject: [PATCH] chore: refactor NewRootCmd into separate pkg (#535) --- cmd/celestia-appd/{ => cmd}/root.go | 6 ++++-- cmd/celestia-appd/main.go | 8 ++++---- 2 files changed, 8 insertions(+), 6 deletions(-) rename cmd/celestia-appd/{ => cmd}/root.go (99%) diff --git a/cmd/celestia-appd/root.go b/cmd/celestia-appd/cmd/root.go similarity index 99% rename from cmd/celestia-appd/root.go rename to cmd/celestia-appd/cmd/root.go index a91d994b45..56a62b91db 100644 --- a/cmd/celestia-appd/root.go +++ b/cmd/celestia-appd/cmd/root.go @@ -1,4 +1,4 @@ -package main +package cmd import ( "fmt" @@ -36,6 +36,8 @@ import ( dbm "github.com/tendermint/tm-db" ) +const EnvPrefix = "CELESTIA" + // NewRootCmd creates a new root command for celestia-appd. It is called once in the // main function. func NewRootCmd() *cobra.Command { @@ -56,7 +58,7 @@ func NewRootCmd() *cobra.Command { WithAccountRetriever(types.AccountRetriever{}). WithBroadcastMode(flags.BroadcastBlock). WithHomeDir(app.DefaultNodeHome). - WithViper(envPrefix) + WithViper(EnvPrefix) rootCmd := &cobra.Command{ Use: "celestia-appd", diff --git a/cmd/celestia-appd/main.go b/cmd/celestia-appd/main.go index 41c9d58aff..e61b22ebe8 100644 --- a/cmd/celestia-appd/main.go +++ b/cmd/celestia-appd/main.go @@ -4,14 +4,14 @@ import ( "os" "github.com/celestiaorg/celestia-app/app" + "github.com/celestiaorg/celestia-app/cmd/celestia-appd/cmd" + svrcmd "github.com/cosmos/cosmos-sdk/server/cmd" ) -const envPrefix = "CELESTIA" - func main() { - rootCmd := NewRootCmd() - if err := svrcmd.Execute(rootCmd, envPrefix, app.DefaultNodeHome); err != nil { + rootCmd := cmd.NewRootCmd() + if err := svrcmd.Execute(rootCmd, cmd.EnvPrefix, app.DefaultNodeHome); err != nil { os.Exit(1) } }