Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKris Budhram <krisbudhram@users.noreply.github.com>2018-11-18 06:20:43 +0300
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2018-11-18 21:09:28 +0300
commite82b2dc8c1628f2da33e5fb0bae1b03e0594ad2c (patch)
treee4f66ce1f18c6361ed522e391b91185435008f3b /commands
parent5df2b79dd2734e9a00ed1692328f58c385676468 (diff)
Fix ignored --config flag with 'new' command
Diffstat (limited to 'commands')
-rw-r--r--commands/commands.go3
-rw-r--r--commands/new.go26
2 files changed, 14 insertions, 15 deletions
diff --git a/commands/commands.go b/commands/commands.go
index 1bbcf8038..0a6ea8860 100644
--- a/commands/commands.go
+++ b/commands/commands.go
@@ -18,7 +18,6 @@ import (
"github.com/gohugoio/hugo/config"
"github.com/gohugoio/hugo/helpers"
"github.com/spf13/cobra"
-
"github.com/spf13/nitro"
)
@@ -46,7 +45,7 @@ func (b *commandsBuilder) addAll() *commandsBuilder {
newCheckCmd(),
b.newBenchmarkCmd(),
newConvertCmd(),
- newNewCmd(),
+ b.newNewCmd(),
newListCmd(),
newImportCmd(),
newGenCmd(),
diff --git a/commands/new.go b/commands/new.go
index ffca86a3e..f10369837 100644
--- a/commands/new.go
+++ b/commands/new.go
@@ -30,16 +30,14 @@ import (
var _ cmder = (*newCmd)(nil)
type newCmd struct {
- hugoBuilderCommon
contentEditor string
contentType string
- *baseCmd
+ *baseBuilderCmd
}
-func newNewCmd() *newCmd {
- cc := &newCmd{}
- cc.baseCmd = newBaseCmd(&cobra.Command{
+func (b *commandsBuilder) newNewCmd() *newCmd {
+ cmd := &cobra.Command{
Use: "new [path]",
Short: "Create new content for your site",
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.
Ensure you run this within the root directory of your site.`,
+ }
+
+ cc := &newCmd{baseBuilderCmd: b.newBuilderCmd(cmd)}
- RunE: cc.newContent,
- })
+ cmd.Flags().StringVarP(&cc.contentType, "kind", "k", "", "content type to create")
+ cmd.PersistentFlags().StringVarP(&cc.source, "source", "s", "", "filesystem path to read files relative from")
+ cmd.PersistentFlags().SetAnnotation("source", cobra.BashCompSubdirsInDir, []string{})
+ cmd.Flags().StringVar(&cc.contentEditor, "editor", "", "edit new content with this editor, if provided")
- cc.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")
- cc.cmd.PersistentFlags().SetAnnotation("source", cobra.BashCompSubdirsInDir, []string{})
- cc.cmd.Flags().StringVar(&cc.contentEditor, "editor", "", "edit new content with this editor, if provided")
+ cmd.AddCommand(newNewSiteCmd().getCommand())
+ cmd.AddCommand(newNewThemeCmd().getCommand())
- cc.cmd.AddCommand(newNewSiteCmd().getCommand())
- cc.cmd.AddCommand(newNewThemeCmd().getCommand())
+ cmd.RunE = cc.newContent
return cc
}