From 0df4df94d6352f221889c5e6f9802e12f659c886 Mon Sep 17 00:00:00 2001 From: Jacob Bednarz Date: Tue, 29 Sep 2020 10:49:50 +1000 Subject: [PATCH] root: Show usage by default If arguments aren't passed in, show the `cmd.Help()` before exiting. Closes #10 --- cmd/root.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmd/root.go b/cmd/root.go index a68bfde..e73267d 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -2,6 +2,7 @@ package cmd import ( "fmt" + "os" "github.com/99designs/keyring" log "github.com/sirupsen/logrus" @@ -34,6 +35,11 @@ var rootCmd = &cobra.Command{ if verbose { log.SetLevel(log.DebugLevel) } + + if len(args) == 0 { + cmd.Help() + os.Exit(0) + } }, Run: func(cmd *cobra.Command, args []string) {}, }