From c388fe4deb56209708d543d22e2861d6562e3d7f Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 12 Apr 2023 15:44:29 +0200 Subject: [PATCH] cli: make cobra templates a const Saves me from having to look if they're possibly updated/overwritten anywhere in the code. Signed-off-by: Sebastiaan van Stijn --- cli/cobra.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cli/cobra.go b/cli/cobra.go index 6501197ddd..c6ce31dccf 100644 --- a/cli/cobra.go +++ b/cli/cobra.go @@ -426,7 +426,7 @@ func invalidPluginReason(cmd *cobra.Command) string { return cmd.Annotations[pluginmanager.CommandAnnotationPluginInvalid] } -var usageTemplate = `Usage: +const usageTemplate = `Usage: {{- if not .HasSubCommands}} {{.UseLine}}{{end}} {{- if .HasSubCommands}} {{ .CommandPath}}{{- if .HasAvailableFlags}} [OPTIONS]{{end}} COMMAND{{end}} @@ -525,5 +525,5 @@ Run '{{.CommandPath}} COMMAND --help' for more information on a command. {{- end}} ` -var helpTemplate = ` +const helpTemplate = ` {{if or .Runnable .HasSubCommands}}{{.UsageString}}{{end}}`