-
Notifications
You must be signed in to change notification settings - Fork 972
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(cmd/celestia): Only provide necessary flags to aux subcmds
- Loading branch information
Showing
10 changed files
with
89 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,96 +1,66 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
|
||
"github.com/spf13/cobra" | ||
"github.com/spf13/pflag" | ||
|
||
"github.com/celestiaorg/celestia-node/nodebuilder/core" | ||
"github.com/celestiaorg/celestia-node/nodebuilder/gateway" | ||
"github.com/celestiaorg/celestia-node/nodebuilder/header" | ||
"github.com/celestiaorg/celestia-node/nodebuilder/node" | ||
"github.com/celestiaorg/celestia-node/nodebuilder/p2p" | ||
"github.com/celestiaorg/celestia-node/nodebuilder/pruner" | ||
"github.com/celestiaorg/celestia-node/nodebuilder/rpc" | ||
"github.com/celestiaorg/celestia-node/nodebuilder/state" | ||
) | ||
|
||
func NewBridge(options ...func(*cobra.Command, node.Type, []*pflag.FlagSet)) *cobra.Command { | ||
flags := []*pflag.FlagSet{ | ||
NodeFlags(), | ||
p2p.Flags(), | ||
MiscFlags(), | ||
core.Flags(), | ||
rpc.Flags(), | ||
gateway.Flags(), | ||
state.Flags(), | ||
pruner.Flags(), | ||
} | ||
cmd := &cobra.Command{ | ||
Use: "bridge [subcommand]", | ||
Args: cobra.NoArgs, | ||
Short: "Manage your Bridge node", | ||
PersistentPreRun: func(cmd *cobra.Command, args []string) { | ||
ctx := WithNodeType(cmd.Context(), node.Bridge) | ||
cmd.SetContext(ctx) | ||
}, | ||
} | ||
func NewBridge(addFullFlags, addMinFlags func(*cobra.Command, []*pflag.FlagSet)) *cobra.Command { | ||
return createTopLevelCmd(node.Bridge, addFullFlags, addMinFlags) | ||
} | ||
|
||
for _, option := range options { | ||
option(cmd, node.Bridge, flags) | ||
} | ||
return cmd | ||
func NewFull(addFullFlags, addMinFlags func(*cobra.Command, []*pflag.FlagSet)) *cobra.Command { | ||
return createTopLevelCmd(node.Full, addFullFlags, addMinFlags) | ||
} | ||
|
||
func NewLight(options ...func(*cobra.Command, node.Type, []*pflag.FlagSet)) *cobra.Command { | ||
flags := []*pflag.FlagSet{ | ||
NodeFlags(), | ||
p2p.Flags(), | ||
header.Flags(), | ||
MiscFlags(), | ||
core.Flags(), | ||
rpc.Flags(), | ||
gateway.Flags(), | ||
state.Flags(), | ||
pruner.Flags(), | ||
} | ||
cmd := &cobra.Command{ | ||
Use: "light [subcommand]", | ||
Args: cobra.NoArgs, | ||
Short: "Manage your Light node", | ||
PersistentPreRun: func(cmd *cobra.Command, args []string) { | ||
ctx := WithNodeType(cmd.Context(), node.Light) | ||
cmd.SetContext(ctx) | ||
}, | ||
} | ||
for _, option := range options { | ||
option(cmd, node.Light, flags) | ||
} | ||
return cmd | ||
func NewLight(addFullFlags, addMinFlags func(*cobra.Command, []*pflag.FlagSet)) *cobra.Command { | ||
return createTopLevelCmd(node.Light, addFullFlags, addMinFlags) | ||
} | ||
|
||
func NewFull(options ...func(*cobra.Command, node.Type, []*pflag.FlagSet)) *cobra.Command { | ||
func createTopLevelCmd( | ||
nodeType node.Type, | ||
addFullFlags, | ||
addMinFlags func(*cobra.Command, []*pflag.FlagSet), | ||
) *cobra.Command { | ||
minFlags := []*pflag.FlagSet{ | ||
NodeStoreFlag(), | ||
p2p.NetworkFlag(), | ||
} | ||
|
||
flags := []*pflag.FlagSet{ | ||
NodeFlags(), | ||
p2p.Flags(), | ||
header.Flags(), | ||
MiscFlags(), | ||
core.Flags(), | ||
rpc.Flags(), | ||
gateway.Flags(), | ||
state.Flags(), | ||
pruner.Flags(), | ||
} | ||
|
||
cmd := &cobra.Command{ | ||
Use: "full [subcommand]", | ||
Use: fmt.Sprintf("%s [subcommand]", strings.ToLower(nodeType.String())), | ||
Args: cobra.NoArgs, | ||
Short: "Manage your Full node", | ||
PersistentPreRun: func(cmd *cobra.Command, args []string) { | ||
ctx := WithNodeType(cmd.Context(), node.Full) | ||
Short: fmt.Sprintf("Manage your %s node", strings.ToLower(nodeType.String())), | ||
PersistentPreRun: func(cmd *cobra.Command, _ []string) { | ||
ctx := WithNodeType(cmd.Context(), nodeType) | ||
cmd.SetContext(ctx) | ||
}, | ||
} | ||
for _, option := range options { | ||
option(cmd, node.Full, flags) | ||
} | ||
|
||
addFullFlags(cmd, flags) | ||
addMinFlags(cmd, minFlags) | ||
|
||
return cmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters