diff --git a/hermes/cmd/hermes.go b/hermes/cmd/hermes.go index ab13dbef..7567c7e0 100644 --- a/hermes/cmd/hermes.go +++ b/hermes/cmd/hermes.go @@ -8,15 +8,26 @@ const ( flagConfig = "config" ) +// NewRelayer creates a new Relayer command that holds +func NewRelayer() *cobra.Command { + root := &cobra.Command{ + Use: "relayer [command]", + Aliases: []string{"r"}, + Short: "Connect blockchains with an IBC relayer", + SilenceUsage: true, + SilenceErrors: true, + } + root.AddCommand(NewHermes()) + return root +} + // NewHermes creates a new Hermes relayer command that holds // some other sub commands related to hermes relayer. func NewHermes() *cobra.Command { c := &cobra.Command{ - Use: "hermes [command]", - Aliases: []string{"h"}, - Short: "Hermes relayer wrapper", - SilenceUsage: true, - SilenceErrors: true, + Use: "hermes [command]", + Aliases: []string{"h"}, + Short: "Hermes relayer wrapper", } // configure flags. diff --git a/hermes/main.go b/hermes/main.go index 2c6ebd68..b3ff60ec 100644 --- a/hermes/main.go +++ b/hermes/main.go @@ -14,16 +14,18 @@ type app struct{} func (app) Manifest(context.Context) (*plugin.Manifest, error) { m := &plugin.Manifest{Name: "hermes"} - m.ImportCobraCommand(cmd.NewHermes(), "ignite relayer") + m.ImportCobraCommand(cmd.NewRelayer(), "ignite") return m, nil } func (app) Execute(_ context.Context, c *plugin.ExecutedCommand, _ plugin.ClientAPI) error { - // Run the "hermes" command as if it were a root command. To do - // so remove the first two arguments which are "ignite relayer" - // from OSArgs to treat "hermes" as the root command. - os.Args = c.OsArgs[2:] - return cmd.NewHermes().Execute() + // Instead of a switch on c.Use, we run the root command like if + // we were in a command line context. This implies to set os.Args + // correctly. + // Remove the first arg "ignite" from OsArgs because our hermes + // command root is "relayer" not "ignite". + os.Args = c.OsArgs[1:] + return cmd.NewRelayer().Execute() } func (app) ExecuteHookPre(context.Context, *plugin.ExecutedHook, plugin.ClientAPI) error { diff --git a/tools/debug/main.go b/tools/debug/main.go index 24a05a5d..30b4f6dc 100644 --- a/tools/debug/main.go +++ b/tools/debug/main.go @@ -35,7 +35,7 @@ func main() { // Add apps with cobra commands. rootCmd.AddCommand( - hermes.NewHermes(), + hermes.NewRelayer(), marketplace.NewMarketplace(), wasm.NewWasm(), // Add cobra commands for debugging here.