Skip to content

Commit

Permalink
Add TOML as an output format
Browse files Browse the repository at this point in the history
  • Loading branch information
twpayne committed Feb 5, 2019
1 parent b41824c commit 8d8fb55
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"text/template"
"unicode"

"github.com/BurntSushi/toml"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/twpayne/chezmoi/lib/chezmoi"
Expand Down Expand Up @@ -64,6 +65,9 @@ var (
e.SetIndent("", " ")
return e.Encode(value)
},
"toml": func(w io.Writer, value interface{}) error {
return toml.NewEncoder(w).Encode(value)
},
"yaml": func(w io.Writer, value interface{}) error {
return yaml.NewEncoder(w).Encode(value)
},
Expand Down
2 changes: 1 addition & 1 deletion cmd/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func init() {
rootCmd.AddCommand(dataCmd)

persistentFlags := dataCmd.PersistentFlags()
persistentFlags.StringVarP(&config.data.format, "format", "f", "json", "format (JSON or YAML)")
persistentFlags.StringVarP(&config.data.format, "format", "f", "json", "format (JSON, TOML, or YAML)")
}

func (c *Config) runDataCmd(fs vfs.FS, args []string) error {
Expand Down
2 changes: 1 addition & 1 deletion cmd/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func init() {
rootCmd.AddCommand(dumpCmd)

persistentFlags := dumpCmd.PersistentFlags()
persistentFlags.StringVarP(&config.dump.format, "format", "f", "json", "format (JSON or YAML)")
persistentFlags.StringVarP(&config.dump.format, "format", "f", "json", "format (JSON, TOML, or YAML)")
persistentFlags.BoolVarP(&config.dump.recursive, "recursive", "r", true, "recursive")
}

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module github.com/twpayne/chezmoi

require (
github.com/BurntSushi/toml v0.3.1 // indirect
github.com/BurntSushi/toml v0.3.1
github.com/Masterminds/semver v1.4.2 // indirect
github.com/Masterminds/sprig v2.17.1+incompatible
github.com/aokoli/goutils v1.1.0 // indirect
Expand Down

0 comments on commit 8d8fb55

Please sign in to comment.