mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
Fix ignored --config flag with 'new' command
This commit is contained in:
parent
5df2b79dd2
commit
e82b2dc8c1
2 changed files with 14 additions and 15 deletions
|
@ -18,7 +18,6 @@ import (
|
||||||
"github.com/gohugoio/hugo/config"
|
"github.com/gohugoio/hugo/config"
|
||||||
"github.com/gohugoio/hugo/helpers"
|
"github.com/gohugoio/hugo/helpers"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"github.com/spf13/nitro"
|
"github.com/spf13/nitro"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -46,7 +45,7 @@ func (b *commandsBuilder) addAll() *commandsBuilder {
|
||||||
newCheckCmd(),
|
newCheckCmd(),
|
||||||
b.newBenchmarkCmd(),
|
b.newBenchmarkCmd(),
|
||||||
newConvertCmd(),
|
newConvertCmd(),
|
||||||
newNewCmd(),
|
b.newNewCmd(),
|
||||||
newListCmd(),
|
newListCmd(),
|
||||||
newImportCmd(),
|
newImportCmd(),
|
||||||
newGenCmd(),
|
newGenCmd(),
|
||||||
|
|
|
@ -30,16 +30,14 @@ import (
|
||||||
var _ cmder = (*newCmd)(nil)
|
var _ cmder = (*newCmd)(nil)
|
||||||
|
|
||||||
type newCmd struct {
|
type newCmd struct {
|
||||||
hugoBuilderCommon
|
|
||||||
contentEditor string
|
contentEditor string
|
||||||
contentType string
|
contentType string
|
||||||
|
|
||||||
*baseCmd
|
*baseBuilderCmd
|
||||||
}
|
}
|
||||||
|
|
||||||
func newNewCmd() *newCmd {
|
func (b *commandsBuilder) newNewCmd() *newCmd {
|
||||||
cc := &newCmd{}
|
cmd := &cobra.Command{
|
||||||
cc.baseCmd = newBaseCmd(&cobra.Command{
|
|
||||||
Use: "new [path]",
|
Use: "new [path]",
|
||||||
Short: "Create new content for your site",
|
Short: "Create new content for your site",
|
||||||
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.
|
||||||
|
@ -50,17 +48,19 @@ You can also specify the kind with ` + "`-k KIND`" + `.
|
||||||
If archetypes are provided in your theme or site, they will be used.
|
If archetypes are provided in your theme or site, they will be used.
|
||||||
|
|
||||||
Ensure you run this within the root directory of your site.`,
|
Ensure you run this within the root directory of your site.`,
|
||||||
|
}
|
||||||
|
|
||||||
RunE: cc.newContent,
|
cc := &newCmd{baseBuilderCmd: b.newBuilderCmd(cmd)}
|
||||||
})
|
|
||||||
|
|
||||||
cc.cmd.Flags().StringVarP(&cc.contentType, "kind", "k", "", "content type to create")
|
cmd.Flags().StringVarP(&cc.contentType, "kind", "k", "", "content type to create")
|
||||||
cc.cmd.PersistentFlags().StringVarP(&cc.source, "source", "s", "", "filesystem path to read files relative from")
|
cmd.PersistentFlags().StringVarP(&cc.source, "source", "s", "", "filesystem path to read files relative from")
|
||||||
cc.cmd.PersistentFlags().SetAnnotation("source", cobra.BashCompSubdirsInDir, []string{})
|
cmd.PersistentFlags().SetAnnotation("source", cobra.BashCompSubdirsInDir, []string{})
|
||||||
cc.cmd.Flags().StringVar(&cc.contentEditor, "editor", "", "edit new content with this editor, if provided")
|
cmd.Flags().StringVar(&cc.contentEditor, "editor", "", "edit new content with this editor, if provided")
|
||||||
|
|
||||||
cc.cmd.AddCommand(newNewSiteCmd().getCommand())
|
cmd.AddCommand(newNewSiteCmd().getCommand())
|
||||||
cc.cmd.AddCommand(newNewThemeCmd().getCommand())
|
cmd.AddCommand(newNewThemeCmd().getCommand())
|
||||||
|
|
||||||
|
cmd.RunE = cc.newContent
|
||||||
|
|
||||||
return cc
|
return cc
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue