diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2021-06-27 15:58:24 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2021-06-27 16:08:28 +0200 |
commit | 6a365c2712c7607e067e192d213b266f0c88d0f3 (patch) | |
tree | dac4470b9f790758af727c2ed4887e41d0e2617d /commands/config.go | |
parent | 19aa95fc7f4cd58dcc8a8ff075762cfc86d41dc3 (diff) |
commands: Add some more info to "hugo config mounts"
* Add owner path and version.
* Also add thme meta info and Hugo version when run with -v flag
Diffstat (limited to 'commands/config.go')
-rw-r--r-- | commands/config.go | 49 |
1 files changed, 41 insertions, 8 deletions
diff --git a/commands/config.go b/commands/config.go index 7ab429308..56692651c 100644 --- a/commands/config.go +++ b/commands/config.go @@ -69,7 +69,7 @@ func (c *configCmd) printMounts(cmd *cobra.Command, args []string) error { allModules := cfg.Cfg.Get("allmodules").(modules.Modules) for _, m := range allModules { - if err := parser.InterfaceToConfig(&modMounts{m: m}, metadecoders.JSON, os.Stdout); err != nil { + if err := parser.InterfaceToConfig(&modMounts{m: m, verbose: c.verbose}, metadecoders.JSON, os.Stdout); err != nil { return err } } @@ -115,7 +115,8 @@ func (c *configCmd) printConfig(cmd *cobra.Command, args []string) error { } type modMounts struct { - m modules.Module + verbose bool + m modules.Module } type modMount struct { @@ -135,13 +136,45 @@ func (m *modMounts) MarshalJSON() ([]byte, error) { }) } + var ownerPath string + if m.m.Owner() != nil { + ownerPath = m.m.Owner().Path() + } + + if m.verbose { + config := m.m.Config() + return json.Marshal(&struct { + Path string `json:"path"` + Version string `json:"version"` + Owner string `json:"owner"` + Dir string `json:"dir"` + Meta map[string]interface{} `json:"meta"` + HugoVersion modules.HugoVersion `json:"hugoVersion"` + + Mounts []modMount `json:"mounts"` + }{ + Path: m.m.Path(), + Version: m.m.Version(), + Owner: ownerPath, + Dir: m.m.Dir(), + Meta: config.Params, + HugoVersion: config.HugoVersion, + Mounts: mounts, + }) + } + return json.Marshal(&struct { - Path string `json:"path"` - Dir string `json:"dir"` - Mounts []modMount `json:"mounts"` + Path string `json:"path"` + Version string `json:"version"` + Owner string `json:"owner"` + Dir string `json:"dir"` + Mounts []modMount `json:"mounts"` }{ - Path: m.m.Path(), - Dir: m.m.Dir(), - Mounts: mounts, + Path: m.m.Path(), + Version: m.m.Version(), + Owner: ownerPath, + Dir: m.m.Dir(), + Mounts: mounts, }) + } |