summaryrefslogtreecommitdiffhomepage
path: root/commands/convert.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2020-01-31 09:09:11 +0100
committerBjørn Erik Pedersen <[email protected]>2020-01-31 16:36:36 +0100
commit2bbc865f7bb713b2d0d2dbb02b90ae2621ad5367 (patch)
treecda2d88ec0079293780028d3f0fe699f839777e7 /commands/convert.go
parent0792cfa9fae94a06a31e393a46fed3b1dd73b66a (diff)
downloadhugo-2bbc865f7bb713b2d0d2dbb02b90ae2621ad5367.tar.gz
hugo-2bbc865f7bb713b2d0d2dbb02b90ae2621ad5367.zip
commands: Fix config environment handling
Fixes #6503 Fixes #6824
Diffstat (limited to 'commands/convert.go')
-rw-r--r--commands/convert.go20
1 files changed, 9 insertions, 11 deletions
diff --git a/commands/convert.go b/commands/convert.go
index e4ff1ac61..b9129e594 100644
--- a/commands/convert.go
+++ b/commands/convert.go
@@ -44,27 +44,25 @@ var (
)
type convertCmd struct {
- hugoBuilderCommon
-
outputDir string
unsafe bool
- *baseCmd
+ *baseBuilderCmd
}
-func newConvertCmd() *convertCmd {
+func (b *commandsBuilder) newConvertCmd() *convertCmd {
cc := &convertCmd{}
- cc.baseCmd = newBaseCmd(&cobra.Command{
+ cmd := &cobra.Command{
Use: "convert",
Short: "Convert your content to different formats",
Long: `Convert your content (e.g. front matter) to different formats.
See convert's subcommands toJSON, toTOML and toYAML for more information.`,
RunE: nil,
- })
+ }
- cc.cmd.AddCommand(
+ cmd.AddCommand(
&cobra.Command{
Use: "toJSON",
Short: "Convert front matter to JSON",
@@ -94,10 +92,10 @@ to use YAML for the front matter.`,
},
)
- cc.cmd.PersistentFlags().StringVarP(&cc.outputDir, "output", "o", "", "filesystem path to write files to")
- cc.cmd.PersistentFlags().StringVarP(&cc.source, "source", "s", "", "filesystem path to read files relative from")
- cc.cmd.PersistentFlags().BoolVar(&cc.unsafe, "unsafe", false, "enable less safe operations, please backup first")
- cc.cmd.PersistentFlags().SetAnnotation("source", cobra.BashCompSubdirsInDir, []string{})
+ cmd.PersistentFlags().StringVarP(&cc.outputDir, "output", "o", "", "filesystem path to write files to")
+ cmd.PersistentFlags().BoolVar(&cc.unsafe, "unsafe", false, "enable less safe operations, please backup first")
+
+ cc.baseBuilderCmd = b.newBuilderBasicCmd(cmd)
return cc
}