cmd/viewcore: dedup 'help' subcommand in interactive mode
Available commands will stop printing 'help' subcommand twice.
Change-Id: Ibf1794cda3283a060271fa6a77b8c72a2855f2ec
Reviewed-on: https://go-review.googlesource.com/128995
Reviewed-by: Heschi Kreinick <heschi@google.com>
diff --git a/cmd/viewcore/main.go b/cmd/viewcore/main.go
index b122b2f..04e82a1 100644
--- a/cmd/viewcore/main.go
+++ b/cmd/viewcore/main.go
@@ -286,7 +286,13 @@
// Create a dummy root to run in shell.
root := &cobra.Command{}
// Make all subcommands of viewcore available in the shell.
- root.AddCommand(cmd.Commands()...)
+ for _, subcmd := range cmd.Commands() {
+ if subcmd.Name() == "help" {
+ root.SetHelpCommand(subcmd)
+ continue
+ }
+ root.AddCommand(subcmd)
+ }
// Also, add exit command to terminate the shell.
root.AddCommand(&cobra.Command{
Use: "exit",