From 019299b0b0bb60355c41ad5364b631f18e7d21ae Mon Sep 17 00:00:00 2001 From: Joe Mooring Date: Sat, 24 Jun 2023 08:45:53 -0700 Subject: [PATCH] commands: Enable format flag with hugo new site Fixes #11155 --- commands/new.go | 15 ++++++++------- testscripts/commands/new.txt | 5 ++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/commands/new.go b/commands/new.go index 1b2a412fd..b5c4d2152 100644 --- a/commands/new.go +++ b/commands/new.go @@ -47,13 +47,13 @@ func newNewCommand() *newCommand { use: "content [path]", short: "Create new content for your site", 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. - - 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.`, +It will guess which kind of file to create based on the path provided. + +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.`, run: func(ctx context.Context, cd *simplecobra.Commandeer, r *rootCommand, args []string) error { if len(args) < 1 { return errors.New("path needs to be provided") @@ -150,6 +150,7 @@ Use ` + "`hugo new [contentPath]`" + ` to create new content.`, }, withc: func(cmd *cobra.Command, r *rootCommand) { cmd.Flags().BoolVarP(&force, "force", "f", false, "init inside non-empty directory") + cmd.Flags().StringVar(&format, "format", "toml", "preferred file format (toml, yaml or json)") }, }, &simpleCommand{ diff --git a/testscripts/commands/new.txt b/testscripts/commands/new.txt index aad0d80f6..92cc3b7da 100644 --- a/testscripts/commands/new.txt +++ b/testscripts/commands/new.txt @@ -2,6 +2,8 @@ hugo new site -h stdout 'Create a new site in the provided directory' +hugo new site my-yaml-site --format yml +checkfile my-yaml-site/hugo.yml hugo new site mysite -f stdout 'Congratulations! Your new Hugo site is created in' cd mysite @@ -45,6 +47,3 @@ draft: true --- Dummy content. - - -