diff --git a/cmd/conf.go b/cmd/conf.go index ef54740..1514636 100644 --- a/cmd/conf.go +++ b/cmd/conf.go @@ -1,11 +1,26 @@ package cmd -import "github.com/spf13/cobra" - -func ConfCmd() *cobra.Command { - return &cobra.Command{ - Use: "conf", - Short: "conf", - Long: `config file`, - } +import ( + "fmt" + + "github.com/spf13/cobra" + "github.com/synctv-org/synctv/internal/bootstrap" + "github.com/synctv-org/synctv/internal/conf" +) + +var ConfCmd = &cobra.Command{ + Use: "conf", + Short: "conf", + Long: `config file`, + RunE: Conf, +} + +func Conf(cmd *cobra.Command, args []string) error { + bootstrap.InitConfig() + fmt.Println(conf.Conf.String()) + return nil +} + +func init() { + RootCmd.AddCommand(ConfCmd) } diff --git a/internal/conf/config.go b/internal/conf/config.go index 00495f1..7ff5dce 100644 --- a/internal/conf/config.go +++ b/internal/conf/config.go @@ -2,6 +2,8 @@ package conf import ( "github.com/synctv-org/synctv/utils" + "github.com/zijiren233/stream" + "gopkg.in/yaml.v3" ) type Config struct { @@ -28,6 +30,11 @@ func (c *Config) Save(file string) error { return utils.WriteYaml(file, c) } +func (c *Config) String() string { + o, _ := yaml.Marshal(c) + return stream.BytesToString(o) +} + func DefaultConfig() *Config { return &Config{ // Global