Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command 'hugo new theme': better error handling #11162

Closed
deining opened this issue Jun 26, 2023 · 2 comments · Fixed by #11178
Closed

Command 'hugo new theme': better error handling #11162

deining opened this issue Jun 26, 2023 · 2 comments · Fixed by #11178

Comments

@deining
Copy link
Contributor

deining commented Jun 26, 2023

The command new theme panics if no argument name is given for the name of the theme:

hugo v.0.114.1 (panic)

$ hugo new theme
panic: runtime error: index out of range [0] with length 0

goroutine 1 [running]:
github.com/gohugoio/hugo/commands.newNewCommand.func5({0x0?, 0x0?}, 0x0?, 0xc000dbaa00, {0x3aa2188, 0x0, 0x0?})
        /root/project/hugo/commands/new.go:170 +0xa48
github.com/gohugoio/hugo/commands.(*simpleCommand).Run(0x0?, {0x2ab0228?, 0xc0000380f8?}, 0x0?, {0x3aa2188?, 0x0?, 0x0?})
        /root/project/hugo/commands/commandeer.go:597 +0x43
github.com/bep/simplecobra.(*Commandeer).compile.func1(0xc000005800?, {0x3aa2188?, 0x0?, 0x0?})
        /root/project/gomodcache/github.com/bep/simplecobra@v0.3.2/simplecobra.go:113 +0x52
github.com/spf13/cobra.(*Command).execute(0xc000005800, {0x3aa2188, 0x0, 0x0})
        /root/project/gomodcache/github.com/spf13/cobra@v1.7.0/command.go:940 +0x862
github.com/spf13/cobra.(*Command).ExecuteC(0xc000d7c300)
        /root/project/gomodcache/github.com/spf13/cobra@v1.7.0/command.go:1068 +0x3bd
github.com/spf13/cobra.(*Command).ExecuteContextC(...)
        /root/project/gomodcache/github.com/spf13/cobra@v1.7.0/command.go:1001
github.com/bep/simplecobra.(*Exec).Execute(0xc00000a738, {0x2ab0228?, 0xc0000380f8?}, {0xc000058090?, 0x195b28?, 0xc000081138?})
        /root/project/gomodcache/github.com/bep/simplecobra@v0.3.2/simplecobra.go:155 +0xd9
github.com/gohugoio/hugo/commands.Execute({0xc000058090, 0x2, 0x3})
        /root/project/hugo/commands/commandeer.go:66 +0x312
main.main()
        /root/project/hugo/main.go:25 +0x65

This wasn't the case with previous versions:

hugo v.0.101 (error message, no panic)

$ hugo_0.101.0.exe new theme
Error: theme name needs to be provided


Usage:
  hugo new theme [name] [flags]

Flags:
  -h, --help   help for theme

Global Flags:
      --clock string               set the clock used by Hugo, e.g. --clock 2021-11-06T22:30:00.00+09:00
      --config string              config file (default is path/config.yaml|json|toml)
      --configDir string           config dir (default "config")
      --debug                      debug output
  -e, --environment string         build environment
      --ignoreVendorPaths string   ignores any _vendor for module paths matching the given Glob pattern
      --log                        enable Logging
      --logFile string             log File path (if set, logging enabled automatically)
      --quiet                      build in quiet mode
  -s, --source string              filesystem path to read files relative from
      --themesDir string           filesystem path to themes directory
  -v, --verbose                    verbose output
      --verboseLog                 verbose logging

Does this issue reproduce with the latest release?

Yes

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants
@deining and others