Skip to content

Commit

Permalink
feat(cmd/celestia): main function with full and light commands
Browse files Browse the repository at this point in the history
  • Loading branch information
Wondertan committed Sep 29, 2021
1 parent 8f85b32 commit 6281d44
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 21 deletions.
11 changes: 8 additions & 3 deletions cmd/celestia/full.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@ package main
import (
"github.com/spf13/cobra"

"github.com/celestiaorg/celestia-node/cmd"
"github.com/celestiaorg/celestia-node/node"
)

func init() {
fullCmd.AddCommand(initCmd)
fullCmd.Annotations[tp] = node.Full.String()
fullCmd.PersistentFlags().StringP("repository", "r", "~/.celestia-full", "The root/home directory for your Celestial Full Node")
const repoName = "repository"
fullCmd.AddCommand(cmd.Init(repoName, node.Full))
fullCmd.PersistentFlags().StringP(repoName,
"r",
"~/.celestia-full",
"The root/home directory of your Celestial Full Node",
)
}

var fullCmd = &cobra.Command{
Expand Down
12 changes: 9 additions & 3 deletions cmd/celestia/light.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@ package main
import (
"github.com/spf13/cobra"

"github.com/celestiaorg/celestia-node/cmd"
"github.com/celestiaorg/celestia-node/node"
)

func init() {
lightCmd.AddCommand(lightCmd)
lightCmd.Annotations[tp] = node.Light.String()
lightCmd.PersistentFlags().String("repository", "~/.celestia-light", "The root/home directory for your Celestial Light Node")
const repoName = "repository"
lightCmd.AddCommand(cmd.Init(repoName, node.Light))
lightCmd.PersistentFlags().StringP(
repoName,
"r",
"~/.celestia-light",
"The root/home directory of your Celestial Light Node",
)
}

var lightCmd = &cobra.Command{
Expand Down
18 changes: 3 additions & 15 deletions cmd/celestia/main.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package main

import (
logging "github.com/ipfs/go-log/v2"
"github.com/spf13/cobra"

"github.com/celestiaorg/celestia-node/node"
)

func init() {
rootCmd.AddCommand(fullCmd)
rootCmd.AddCommand(lightCmd)
rootCmd.AddCommand(fullCmd, lightCmd)
}

func main() {
Expand All @@ -19,20 +17,10 @@ func main() {
}

func run() error {
logging.SetAllLoggers(logging.LevelInfo)
return rootCmd.Execute()
}

var rootCmd = &cobra.Command{
Use: "celestia [subcommand]",
}

const tp = "type"

var initCmd = &cobra.Command{
RunE: func(cmd *cobra.Command, args []string) error {
tp := node.ParseType(cmd.Annotations["type"])
path := cmd.Flag("repository").Value.String()
node.Init(path, )
},
}

0 comments on commit 6281d44

Please sign in to comment.