From 71a32c289e787e357b768dcc5059cf9d950f94a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Fri, 5 May 2023 09:18:37 +0200 Subject: [PATCH] More script work --- commandsnew/{hugo.go => aardvark.go} | 0 commandsnew/convert.go | 45 ++++++++++++++++++++ main_test.go | 1 + testscripts/commands/gen.txt | 2 +- testscripts/{unfinished => commands}/mod.txt | 0 testscripts/unfinished/convert.txt | 4 ++ 6 files changed, 51 insertions(+), 1 deletion(-) rename commandsnew/{hugo.go => aardvark.go} (100%) create mode 100644 commandsnew/convert.go rename testscripts/{unfinished => commands}/mod.txt (100%) create mode 100644 testscripts/unfinished/convert.txt diff --git a/commandsnew/hugo.go b/commandsnew/aardvark.go similarity index 100% rename from commandsnew/hugo.go rename to commandsnew/aardvark.go diff --git a/commandsnew/convert.go b/commandsnew/convert.go new file mode 100644 index 00000000000..20f152964e3 --- /dev/null +++ b/commandsnew/convert.go @@ -0,0 +1,45 @@ +package commandsnew + +import ( + "context" + + "github.com/bep/simplecobra" + ck "github.com/bep/simplecobra" + "github.com/spf13/cobra" +) + +func newConvertCommand() *convertCommand { + return &convertCommand{ + commands: []simplecobra.Commander{}, + } + +} + +type convertCommand struct { + r *rootCommand + + commands []ck.Commander +} + +func (c *convertCommand) Commands() []simplecobra.Commander { + return c.commands +} + +func (c *convertCommand) Name() string { + return "convert" +} + +func (c *convertCommand) Run(ctx context.Context, cd *simplecobra.Commandeer, args []string) error { + return nil +} + +func (c *convertCommand) WithCobraCommand(cmd *cobra.Command) error { + cmd.Short = "Print the site configuration" + cmd.Long = `Print the site configuration, both default and custom settings.` + return nil +} + +func (c *convertCommand) Init(cd *simplecobra.Commandeer) error { + c.r = cd.Root.Command.(*rootCommand) + return nil +} diff --git a/main_test.go b/main_test.go index 2bc47d87bc0..09d7d76ed76 100644 --- a/main_test.go +++ b/main_test.go @@ -84,6 +84,7 @@ func testSetupFunc() func(env *testscript.Env) error { goVersion := runtime.Version() // Strip all but the major and minor version. goVersion = regexp.MustCompile(`^go(\d+\.\d+)`).FindStringSubmatch(goVersion)[1] + keyVals = append(keyVals, "GOVERSION", goVersion) envhelpers.SetEnvVars(&env.Vars, keyVals...) return nil diff --git a/testscripts/commands/gen.txt b/testscripts/commands/gen.txt index e896d4d25f5..64403154401 100644 --- a/testscripts/commands/gen.txt +++ b/testscripts/commands/gen.txt @@ -1,6 +1,6 @@ # Test the gen commands. # Note that adding new commands will require updating the NUM_COMMANDS value. -env NUM_COMMANDS=34 +env NUM_COMMANDS=37 hugo gen -h stdout 'A collection of several useful generators\.' diff --git a/testscripts/unfinished/mod.txt b/testscripts/commands/mod.txt similarity index 100% rename from testscripts/unfinished/mod.txt rename to testscripts/commands/mod.txt diff --git a/testscripts/unfinished/convert.txt b/testscripts/unfinished/convert.txt new file mode 100644 index 00000000000..11d064c01d4 --- /dev/null +++ b/testscripts/unfinished/convert.txt @@ -0,0 +1,4 @@ +# Test the convert commands. + +hugo convert -h +stdout 'asdfsdf' \ No newline at end of file