commands: Use consistent style when describing subcommands

Closes #12897

Change-Id: Ib27a4a7b540d45243e6252db769d4b9fb7447718
Signed-off-by: Rohan Hasabe <rohanhasabe8@gmail.com>
This commit is contained in:
Rohan Hasabe 2024-10-13 22:10:38 -04:00 committed by Bjørn Erik Pedersen
parent 4985be1a4a
commit 6b5e117a12
16 changed files with 27 additions and 26 deletions

View file

@ -509,7 +509,7 @@ func (r *rootCommand) initRootCommand(subCommandName string, cd *simplecobra.Com
commandName = subCommandName commandName = subCommandName
} }
cmd.Use = fmt.Sprintf("%s [flags]", commandName) cmd.Use = fmt.Sprintf("%s [flags]", commandName)
cmd.Short = fmt.Sprintf("%s builds your site", commandName) cmd.Short = "Build your site"
cmd.Long = `COMMAND_NAME is the main command, used to build your Hugo site. cmd.Long = `COMMAND_NAME is the main command, used to build your Hugo site.
Hugo is a Fast and Flexible Static Site Generator Hugo is a Fast and Flexible Static Site Generator

View file

@ -110,8 +110,8 @@ func (c *configCommand) Run(ctx context.Context, cd *simplecobra.Commandeer, arg
func (c *configCommand) Init(cd *simplecobra.Commandeer) error { func (c *configCommand) Init(cd *simplecobra.Commandeer) error {
c.r = cd.Root.Command.(*rootCommand) c.r = cd.Root.Command.(*rootCommand)
cmd := cd.CobraCommand cmd := cd.CobraCommand
cmd.Short = "Print the site configuration" cmd.Short = "Display site configuration"
cmd.Long = `Print the site configuration, both default and custom settings.` cmd.Long = `Display site configuration, both default and custom settings.`
cmd.Flags().StringVar(&c.format, "format", "toml", "preferred file format (toml, yaml or json)") cmd.Flags().StringVar(&c.format, "format", "toml", "preferred file format (toml, yaml or json)")
_ = cmd.RegisterFlagCompletionFunc("format", cobra.FixedCompletions([]string{"toml", "yaml", "json"}, cobra.ShellCompDirectiveNoFileComp)) _ = cmd.RegisterFlagCompletionFunc("format", cobra.FixedCompletions([]string{"toml", "yaml", "json"}, cobra.ShellCompDirectiveNoFileComp))
cmd.Flags().StringVar(&c.lang, "lang", "", "the language to display config for. Defaults to the first language defined.") cmd.Flags().StringVar(&c.lang, "lang", "", "the language to display config for. Defaults to the first language defined.")

View file

@ -105,8 +105,8 @@ func (c *convertCommand) Run(ctx context.Context, cd *simplecobra.Commandeer, ar
func (c *convertCommand) Init(cd *simplecobra.Commandeer) error { func (c *convertCommand) Init(cd *simplecobra.Commandeer) error {
cmd := cd.CobraCommand cmd := cd.CobraCommand
cmd.Short = "Convert your content to different formats" cmd.Short = "Convert front matter to another format"
cmd.Long = `Convert your content (e.g. front matter) to different formats. cmd.Long = `Convert front matter to another format.
See convert's subcommands toJSON, toTOML and toYAML for more information.` See convert's subcommands toJSON, toTOML and toYAML for more information.`

View file

@ -42,8 +42,8 @@ import (
func newDeployCommand() simplecobra.Commander { func newDeployCommand() simplecobra.Commander {
return &simpleCommand{ return &simpleCommand{
name: "deploy", name: "deploy",
short: "Deploy your site to a Cloud provider.", short: "Deploy your site to a cloud provider",
long: `Deploy your site to a Cloud provider. long: `Deploy your site to a cloud provider
See https://gohugo.io/hosting-and-deployment/hugo-deploy/ for detailed See https://gohugo.io/hosting-and-deployment/hugo-deploy/ for detailed
documentation. documentation.

View file

@ -25,8 +25,8 @@ import (
func newEnvCommand() simplecobra.Commander { func newEnvCommand() simplecobra.Commander {
return &simpleCommand{ return &simpleCommand{
name: "env", name: "env",
short: "Print Hugo version and environment info", short: "Display version and environment info",
long: "Print Hugo version and environment info. This is useful in Hugo bug reports", long: "Display version and environment info. This is useful in Hugo bug reports",
run: func(ctx context.Context, cd *simplecobra.Commandeer, r *rootCommand, args []string) error { run: func(ctx context.Context, cd *simplecobra.Commandeer, r *rootCommand, args []string) error {
r.Printf("%s\n", hugo.BuildVersionString()) r.Printf("%s\n", hugo.BuildVersionString())
r.Printf("GOOS=%q\n", runtime.GOOS) r.Printf("GOOS=%q\n", runtime.GOOS)
@ -61,8 +61,8 @@ func newVersionCmd() simplecobra.Commander {
r.Println(hugo.BuildVersionString()) r.Println(hugo.BuildVersionString())
return nil return nil
}, },
short: "Print Hugo version and environment info", short: "Display version",
long: "Print Hugo version and environment info. This is useful in Hugo bug reports.", long: "Display version and environment info. This is useful in Hugo bug reports.",
withc: func(cmd *cobra.Command, r *rootCommand) { withc: func(cmd *cobra.Command, r *rootCommand) {
cmd.ValidArgsFunction = cobra.NoFileCompletions cmd.ValidArgsFunction = cobra.NoFileCompletions
}, },

View file

@ -273,7 +273,8 @@ func (c *genCommand) Run(ctx context.Context, cd *simplecobra.Commandeer, args [
func (c *genCommand) Init(cd *simplecobra.Commandeer) error { func (c *genCommand) Init(cd *simplecobra.Commandeer) error {
cmd := cd.CobraCommand cmd := cd.CobraCommand
cmd.Short = "A collection of several useful generators." cmd.Short = "Generate documentation and syntax highlighting styles"
cmd.Long = "Generate documentation for your project using Hugo's documentation engine, including syntax highlighting for various programming languages."
cmd.RunE = nil cmd.RunE = nil
return nil return nil

View file

@ -90,8 +90,8 @@ func (c *importCommand) Run(ctx context.Context, cd *simplecobra.Commandeer, arg
func (c *importCommand) Init(cd *simplecobra.Commandeer) error { func (c *importCommand) Init(cd *simplecobra.Commandeer) error {
cmd := cd.CobraCommand cmd := cd.CobraCommand
cmd.Short = "Import your site from others." cmd.Short = "Import a site from another system"
cmd.Long = `Import your site from other web site generators like Jekyll. cmd.Long = `Import a site from another system.
Import requires a subcommand, e.g. ` + "`hugo import jekyll jekyll_root_path target_path`." Import requires a subcommand, e.g. ` + "`hugo import jekyll jekyll_root_path target_path`."

View file

@ -199,8 +199,8 @@ func (c *listCommand) Run(ctx context.Context, cd *simplecobra.Commandeer, args
func (c *listCommand) Init(cd *simplecobra.Commandeer) error { func (c *listCommand) Init(cd *simplecobra.Commandeer) error {
cmd := cd.CobraCommand cmd := cd.CobraCommand
cmd.Short = "Listing out various types of content" cmd.Short = "List content"
cmd.Long = `Listing out various types of content. cmd.Long = `List content.
List requires a subcommand, e.g. hugo list drafts` List requires a subcommand, e.g. hugo list drafts`

View file

@ -328,7 +328,7 @@ func (c *modCommands) Run(ctx context.Context, cd *simplecobra.Commandeer, args
func (c *modCommands) Init(cd *simplecobra.Commandeer) error { func (c *modCommands) Init(cd *simplecobra.Commandeer) error {
cmd := cd.CobraCommand cmd := cd.CobraCommand
cmd.Short = "Various Hugo Modules helpers." cmd.Short = "Manage modules"
cmd.Long = `Various helpers to help manage the modules in your project's dependency graph. cmd.Long = `Various helpers to help manage the modules in your project's dependency graph.
Most operations here requires a Go version installed on your system (>= Go 1.12) and the relevant VCS client (typically Git). Most operations here requires a Go version installed on your system (>= Go 1.12) and the relevant VCS client (typically Git).
This is not needed if you only operate on modules inside /themes or if you have vendored them via "hugo mod vendor". This is not needed if you only operate on modules inside /themes or if you have vendored them via "hugo mod vendor".

View file

@ -40,7 +40,7 @@ func newNewCommand() *newCommand {
&simpleCommand{ &simpleCommand{
name: "content", name: "content",
use: "content [path]", use: "content [path]",
short: "Create new content for your site", short: "Create new content",
long: `Create a new content file and automatically set the date and title. long: `Create a new content file and automatically set the date and title.
It will guess which kind of file to create based on the path provided. It will guess which kind of file to create based on the path provided.
@ -181,7 +181,7 @@ func (c *newCommand) Run(ctx context.Context, cd *simplecobra.Commandeer, args [
func (c *newCommand) Init(cd *simplecobra.Commandeer) error { func (c *newCommand) Init(cd *simplecobra.Commandeer) error {
cmd := cd.CobraCommand cmd := cd.CobraCommand
cmd.Short = "Create new content for your site" cmd.Short = "Create new content"
cmd.Long = `Create a new content file and automatically set the date and title. cmd.Long = `Create a new content file and automatically set the date and title.
It will guess which kind of file to create based on the path provided. It will guess which kind of file to create based on the path provided.

View file

@ -508,7 +508,7 @@ func (c *serverCommand) Run(ctx context.Context, cd *simplecobra.Commandeer, arg
func (c *serverCommand) Init(cd *simplecobra.Commandeer) error { func (c *serverCommand) Init(cd *simplecobra.Commandeer) error {
cmd := cd.CobraCommand cmd := cd.CobraCommand
cmd.Short = "A high performance webserver" cmd.Short = "Start the embedded web server"
cmd.Long = `Hugo provides its own webserver which builds and serves the site. cmd.Long = `Hugo provides its own webserver which builds and serves the site.
While hugo server is high performance, it is a webserver with limited options. While hugo server is high performance, it is a webserver with limited options.

View file

@ -1,7 +1,7 @@
# Test the config command. # Test the config command.
hugo config -h hugo config -h
stdout 'Print the site configuration' stdout 'Display site configuration'
hugo config hugo config

View file

@ -1,7 +1,7 @@
# Test the convert commands. # Test the convert commands.
hugo convert -h hugo convert -h
stdout 'Convert your content' stdout 'Convert front matter to another format'
hugo convert toJSON -h hugo convert toJSON -h
stdout 'to use JSON for the front matter' stdout 'to use JSON for the front matter'
hugo convert toTOML -h hugo convert toTOML -h

View file

@ -1,7 +1,7 @@
# Test the deploy command. # Test the deploy command.
hugo deploy -h hugo deploy -h
stdout 'Deploy your site to a Cloud provider\.' stdout 'Deploy your site to a cloud provider'
mkdir mybucket mkdir mybucket
hugo deploy --target mydeployment --invalidateCDN=false hugo deploy --target mydeployment --invalidateCDN=false
grep 'hello' mybucket/index.html grep 'hello' mybucket/index.html

View file

@ -3,7 +3,7 @@
env NUM_COMMANDS=44 env NUM_COMMANDS=44
hugo gen -h hugo gen -h
stdout 'A collection of several useful generators\.' stdout 'Generate documentation for your project using Hugo''s documentation engine, including syntax highlighting for various programming languages\.'
hugo gen doc --dir clidocs hugo gen doc --dir clidocs
checkfilecount $NUM_COMMANDS clidocs checkfilecount $NUM_COMMANDS clidocs

View file

@ -1,7 +1,7 @@
# Test the import jekyll command. # Test the import + import jekyll command.
hugo import -h hugo import -h
stdout 'Import your site from other web site generators like Jekyll\.' stdout 'Import a site from another system'
hugo import jekyll -h hugo import jekyll -h
stdout 'hugo import from Jekyll\.' stdout 'hugo import from Jekyll\.'