Skip to content

Commit

Permalink
commands: Fix the config command
Browse files Browse the repository at this point in the history
It now also accepts the `-s` (source) flag.

See #4598
  • Loading branch information
bep committed Apr 11, 2018
1 parent 24d5c21 commit f396cff
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions commands/commands_test.go
Expand Up @@ -51,6 +51,7 @@ func TestCommands(t *testing.T) {
// no args = hugo build
{nil, []string{sourceFlag}, ""},
{nil, []string{sourceFlag, "--renderToMemory"}, ""},
{[]string{"config"}, []string{sourceFlag}, ""},
{[]string{"benchmark"}, []string{sourceFlag, "-n=1"}, ""},
{[]string{"convert", "toTOML"}, []string{sourceFlag, "-o=" + filepath.Join(dirOut, "toml")}, ""},
{[]string{"convert", "toYAML"}, []string{sourceFlag, "-o=" + filepath.Join(dirOut, "yaml")}, ""},
Expand Down
5 changes: 4 additions & 1 deletion commands/list_config.go → commands/config.go
Expand Up @@ -25,6 +25,7 @@ import (
var _ cmder = (*configCmd)(nil)

type configCmd struct {
hugoBuilderCommon
*baseCmd
}

Expand All @@ -37,11 +38,13 @@ func newConfigCmd() *configCmd {
RunE: cc.printConfig,
})

cc.cmd.Flags().StringVarP(&cc.source, "source", "s", "", "filesystem path to read files relative from")

return cc
}

func (c *configCmd) printConfig(cmd *cobra.Command, args []string) error {
cfg, err := initializeConfig(false, nil, c, nil)
cfg, err := initializeConfig(false, &c.hugoBuilderCommon, c, nil)

if err != nil {
return err
Expand Down

0 comments on commit f396cff

Please sign in to comment.