diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2023-05-27 15:04:36 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2023-05-27 16:56:54 +0200 |
commit | f86b5f70a60fc3793bc826f2ccd8dcdd62e26b51 (patch) | |
tree | 05cc4ed0e7856dc114787c98689853d195bc291d /commands/new.go | |
parent | 3297b395d8d5fadb45b9055e55458967fb9f4a76 (diff) |
commands: Move the --format flag to only the commands that support it
Fixes #11022
Diffstat (limited to 'commands/new.go')
-rw-r--r-- | commands/new.go | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/commands/new.go b/commands/new.go index 8a2b02293..d021be027 100644 --- a/commands/new.go +++ b/commands/new.go @@ -36,6 +36,7 @@ func newNewCommand() *newCommand { var ( force bool contentType string + format string ) var c *newCommand @@ -67,6 +68,8 @@ func newNewCommand() *newCommand { cmd.Flags().StringVarP(&contentType, "kind", "k", "", "content type to create") cmd.Flags().String("editor", "", "edit new content with this editor, if provided") cmd.Flags().BoolVarP(&force, "force", "f", false, "overwrite file if it already exists") + cmd.Flags().StringVar(&format, "format", "toml", "preferred file format (toml, yaml or json)") + }, }, &simpleCommand{ @@ -118,7 +121,7 @@ Use ` + "`hugo new [contentPath]`" + ` to create new content.`, return errors.New(createpath + " already exists and is not empty. See --force.") case !isEmpty && force: - all := append(dirs, filepath.Join(createpath, "hugo."+r.format)) + all := append(dirs, filepath.Join(createpath, "hugo."+format)) for _, path := range all { if exists, _ := helpers.Exists(path, sourceFs); exists { return errors.New(path + " already exists") @@ -133,7 +136,7 @@ Use ` + "`hugo new [contentPath]`" + ` to create new content.`, } } - c.newSiteCreateConfig(sourceFs, createpath, r.format) + c.newSiteCreateConfig(sourceFs, createpath, format) // Create a default archetype file. helpers.SafeWriteToDisk(filepath.Join(archeTypePath, "default.md"), |