From 0353e2d70400bac30c7e3badba493fecc9fe1763 Mon Sep 17 00:00:00 2001 From: vilmibm Date: Thu, 19 Nov 2020 22:25:16 +0000 Subject: [PATCH] WIP: start on passing through help when appropriate --- main.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index 11ee132..192d419 100644 --- a/main.go +++ b/main.go @@ -16,13 +16,19 @@ import ( const binroot = "/town/commands" var rootCmd = &cobra.Command{ - Use: "town", - Short: "Run commands unique to tilde.town", + Use: "town", + Short: "Run commands unique to tilde.town", + DisableFlagParsing: true, +} + +func init() { + rootCmd.Flags().BoolP("help", "h", false, "") } var adminCmd = &cobra.Command{ - Use: "admin", - Short: "Run administrative commands", + Use: "admin", + Short: "Run administrative commands", + DisableFlagParsing: true, } func isAdmin() (bool, error) { @@ -134,6 +140,7 @@ func execWrapper(executablePath string) func(*cobra.Command, []string) error { } func cli() int { + rootCommand.PersistentFlags().BoolFlagP("help", "h", false) err := parseCommands(rootCmd, "core") if err != nil { fmt.Fprintf(os.Stderr, "failed to parse core commands: %s", err)