From 12646750aa186cf3bf50266f8eddf9cfebc3c9c9 Mon Sep 17 00:00:00 2001 From: Mos Roshanavand Date: Mon, 26 Jun 2023 20:20:24 +0200 Subject: [PATCH] Print help message when triggered with no flags --- commands/convert.go | 1 + commands/gen.go | 2 ++ commands/import.go | 1 + commands/list.go | 1 + commands/new.go | 2 ++ 5 files changed, 7 insertions(+) diff --git a/commands/convert.go b/commands/convert.go index f444e001c..702c9227f 100644 --- a/commands/convert.go +++ b/commands/convert.go @@ -110,6 +110,7 @@ See convert's subcommands toJSON, toTOML and toYAML for more information.` cmd.PersistentFlags().StringVarP(&c.outputDir, "output", "o", "", "filesystem path to write files to") cmd.PersistentFlags().BoolVar(&c.unsafe, "unsafe", false, "enable less safe operations, please backup first") + cmd.RunE = nil return nil } diff --git a/commands/gen.go b/commands/gen.go index c5eab894a..1a3cf2174 100644 --- a/commands/gen.go +++ b/commands/gen.go @@ -243,6 +243,8 @@ func (c *genCommand) Run(ctx context.Context, cd *simplecobra.Commandeer, args [ func (c *genCommand) Init(cd *simplecobra.Commandeer) error { cmd := cd.CobraCommand cmd.Short = "A collection of several useful generators." + + cmd.RunE = nil return nil } diff --git a/commands/import.go b/commands/import.go index 1d37c217d..18ed7b328 100644 --- a/commands/import.go +++ b/commands/import.go @@ -96,6 +96,7 @@ func (c *importCommand) Init(cd *simplecobra.Commandeer) error { Import requires a subcommand, e.g. ` + "`hugo import jekyll jekyll_root_path target_path`." + cmd.RunE = nil return nil } diff --git a/commands/list.go b/commands/list.go index 6458df875..6690ea9ee 100644 --- a/commands/list.go +++ b/commands/list.go @@ -182,6 +182,7 @@ func (c *listCommand) Init(cd *simplecobra.Commandeer) error { List requires a subcommand, e.g. hugo list drafts` + cmd.RunE = nil return nil } diff --git a/commands/new.go b/commands/new.go index 633f1becb..a16453d62 100644 --- a/commands/new.go +++ b/commands/new.go @@ -286,6 +286,8 @@ You can also specify the kind with ` + "`-k KIND`" + `. If archetypes are provided in your theme or site, they will be used. Ensure you run this within the root directory of your site.` + + cmd.RunE = nil return nil }