Skip to content

Commit

Permalink
chore: refactor NewRootCmd into separate pkg (celestiaorg#535)
Browse files Browse the repository at this point in the history
  • Loading branch information
liamsi authored Jul 11, 2022
1 parent 00370a7 commit 19058ba
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 4 additions & 2 deletions cmd/celestia-appd/root.go → cmd/celestia-appd/cmd/root.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package cmd

import (
"fmt"
Expand Down Expand Up @@ -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 {
Expand All @@ -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",
Expand Down
8 changes: 4 additions & 4 deletions cmd/celestia-appd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

0 comments on commit 19058ba

Please sign in to comment.