Skip to content

Commit

Permalink
add show config command
Browse files Browse the repository at this point in the history
  • Loading branch information
reddec committed May 29, 2022
1 parent 537557f commit c923585
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 93,13 @@ state any changes (for legal details please read LICENSE file).
#### show

Usage:
layout [OPTIONS] show <config-file>
layout [OPTIONS] show <config | config-file>

Help Options:
-h, --help Show this help message

Available commands:
config current config
config-file location of default config file

#### new
Expand Down
20 changes: 19 additions & 1 deletion cmd/layout/commands/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 16,16 @@ limitations under the License.

package commands

import "fmt"
import (
"fmt"
"os"

"gopkg.in/yaml.v3"
)

type ShowCommand struct {
ConfigFile ShowConfigFileCommand `command:"config-file" description:"location of default config file"`
Config ShowConfigCommand `command:"config" description:"current config"`
}

type ShowConfigFileCommand struct {
Expand All @@ -29,3 35,15 @@ func (cmd ShowConfigFileCommand) Execute([]string) error {
_, err := fmt.Println(defaultConfigFile())
return err
}

type ShowConfigCommand struct {
ConfigSource
}

func (cmd ShowConfigCommand) Execute([]string) error {
c, err := cmd.readConfig()
if err != nil {
return err
}
return yaml.NewEncoder(os.Stdout).Encode(c)
}

0 comments on commit c923585

Please sign in to comment.