Skip to content

Commit c923585

Browse files
committed
add show config command
1 parent 537557f commit c923585

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,13 @@ state any changes (for legal details please read LICENSE file).
9393
#### show
9494

9595
Usage:
96-
layout [OPTIONS] show <config-file>
96+
layout [OPTIONS] show <config | config-file>
9797

9898
Help Options:
9999
-h, --help Show this help message
100100

101101
Available commands:
102+
config current config
102103
config-file location of default config file
103104

104105
#### new

cmd/layout/commands/show.go

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,16 @@ limitations under the License.
1616

1717
package commands
1818

19-
import "fmt"
19+
import (
20+
"fmt"
21+
"os"
22+
23+
"gopkg.in/yaml.v3"
24+
)
2025

2126
type ShowCommand struct {
2227
ConfigFile ShowConfigFileCommand `command:"config-file" description:"location of default config file"`
28+
Config ShowConfigCommand `command:"config" description:"current config"`
2329
}
2430

2531
type ShowConfigFileCommand struct {
@@ -29,3 +35,15 @@ func (cmd ShowConfigFileCommand) Execute([]string) error {
2935
_, err := fmt.Println(defaultConfigFile())
3036
return err
3137
}
38+
39+
type ShowConfigCommand struct {
40+
ConfigSource
41+
}
42+
43+
func (cmd ShowConfigCommand) Execute([]string) error {
44+
c, err := cmd.readConfig()
45+
if err != nil {
46+
return err
47+
}
48+
return yaml.NewEncoder(os.Stdout).Encode(c)
49+
}

0 commit comments

Comments
 (0)