diff --git a/cmd/auth.go b/cmd/auth.go index 016bf79..33bd47d 100644 --- a/cmd/auth.go +++ b/cmd/auth.go @@ -12,8 +12,14 @@ import ( ) var authCmd = &cobra.Command{ - Use: "auth", - Short: "Authentication commands", + Use: "auth", + Short: "Authentication commands", + SilenceUsage: true, + RunE: func(cmd *cobra.Command, args []string) error { + cmd.SetOut(cmd.ErrOrStderr()) + _ = cmd.Help() + return fmt.Errorf("subcommand required") + }, } var loginCmd = &cobra.Command{ diff --git a/cmd/root.go b/cmd/root.go index 70b5ba4..7544c06 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -1,14 +1,16 @@ package cmd import ( + "fmt" "os" "github.com/spf13/cobra" ) var rootCmd = &cobra.Command{ - Use: "withings-export", - Short: "CLI to export health data from Withings", + Use: "withings-export", + Short: "CLI to export health data from Withings", + SilenceUsage: true, Long: `withings-export reads your personal Withings health data — activity, sleep, workouts, body measurements, intraday samples — and prints it on stdout. Default output is narrow, fitdown-style markdown; pass @@ -16,6 +18,11 @@ stdout. Default output is narrow, fitdown-style markdown; pass LLM agents: run 'withings-export prime' for a one-screen orientation (I/O contract, subcommands, date flags, jq recipes).`, + RunE: func(cmd *cobra.Command, args []string) error { + cmd.SetOut(cmd.ErrOrStderr()) + _ = cmd.Help() + return fmt.Errorf("subcommand required") + }, } func Execute() {