-
Notifications
You must be signed in to change notification settings - Fork 993
/
Copy pathmain.go
74 lines (65 loc) · 1.74 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package main
import (
"context"
"os"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
cmdnode "github.com/celestiaorg/celestia-node/cmd"
)
// WithSubcommands returns the set of commands that require the full flagset.
func WithSubcommands() func(*cobra.Command, []*pflag.FlagSet) {
return func(c *cobra.Command, flags []*pflag.FlagSet) {
c.AddCommand(
cmdnode.Init(flags...),
cmdnode.Start(cmdnode.WithFlagSet(flags)),
)
}
}
// WithAuxiliarySubcommands returns the set of commands that require only the
// minimum flagset for node store determination.
func WithAuxiliarySubcommands() func(*cobra.Command, []*pflag.FlagSet) {
return func(c *cobra.Command, flags []*pflag.FlagSet) {
c.AddCommand(
cmdnode.AuthCmd(flags...),
cmdnode.ResetStore(flags...),
cmdnode.RemoveConfigCmd(flags...),
cmdnode.UpdateConfigCmd(flags...),
)
}
}
func init() {
bridgeCmd := cmdnode.NewBridge(WithSubcommands(), WithAuxiliarySubcommands())
lightCmd := cmdnode.NewLight(WithSubcommands(), WithAuxiliarySubcommands())
fullCmd := cmdnode.NewFull(WithSubcommands(), WithAuxiliarySubcommands())
rootCmd.AddCommand(
bridgeCmd,
lightCmd,
fullCmd,
docgenCmd,
versionCmd,
)
rootCmd.SetHelpCommand(&cobra.Command{})
}
func main() {
err := run()
if err != nil {
os.Exit(1)
}
}
func run() error {
return rootCmd.ExecuteContext(context.Background())
}
var rootCmd = &cobra.Command{
Use: "celestia [ bridge || full || light ] [subcommand]",
Short: `
____ __ __ _
/ ____/__ / /__ _____/ /_(_)___ _
/ / / _ \/ / _ \/ ___/ __/ / __ /
/ /___/ __/ / __(__ ) /_/ / /_/ /
\____/\___/_/\___/____/\__/_/\__,_/
`,
Args: cobra.NoArgs,
CompletionOptions: cobra.CompletionOptions{
DisableDefaultCmd: false,
},
}