mcst-linux-kernel/patches-2024.06.26/lxd-3.0.0/0018-lxc-help-Make-help-res...

51 lines
1.7 KiB
Diff
Raw Permalink Normal View History

2024-07-09 13:51:45 +03:00
From ca4bfce4054e2e90a2ace819888e13240b8716c5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber@ubuntu.com>
Date: Wed, 4 Apr 2018 12:54:58 -0400
Subject: lxc/help: Make help respect --all too
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Closes #4406
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
---
lxc/main.go | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/lxc/main.go b/lxc/main.go
index f558e479..9bda930f 100644
--- a/lxc/main.go
+++ b/lxc/main.go
@@ -58,9 +58,6 @@ For help with any of those, simply call them with --help.`))
app.PersistentFlags().BoolVar(&globalCmd.flagLogDebug, "debug", false, i18n.G("Show all debug messages"))
app.PersistentFlags().BoolVarP(&globalCmd.flagLogVerbose, "verbose", "v", false, i18n.G("Show all information messages"))
- // Local flags
- app.Flags().BoolVar(&globalCmd.flagHelpAll, "all", false, i18n.G("Show less common commands"))
-
// Wrappers
app.PersistentPreRunE = globalCmd.PreRun
app.PersistentPostRunE = globalCmd.PostRun
@@ -193,6 +190,20 @@ For help with any of those, simply call them with --help.`))
versionCmd := cmdVersion{global: &globalCmd}
app.AddCommand(versionCmd.Command())
+ // Get help command
+ app.InitDefaultHelpCmd()
+ var help *cobra.Command
+ for _, cmd := range app.Commands() {
+ if cmd.Name() == "help" {
+ help = cmd
+ break
+ }
+ }
+
+ // Help flags
+ app.Flags().BoolVar(&globalCmd.flagHelpAll, "all", false, i18n.G("Show less common commands"))
+ help.Flags().BoolVar(&globalCmd.flagHelpAll, "all", false, i18n.G("Show less common commands"))
+
// Deal with --all flag
err := app.ParseFlags(os.Args[1:])
if err == nil {