summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/BurntSushi/toml/cmd/tomlv/main.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2016-09-18 19:21:15 +0200
committerWim <wim@42.be>2016-09-18 19:21:15 +0200
commit7baf386edea4c71919b257d99ca7f7e07897c412 (patch)
tree5a6f7f0f506c3ab2d15d91548b1d0479bb8fb1ba /vendor/github.com/BurntSushi/toml/cmd/tomlv/main.go
parent6e410b096ef15e976f6a2d28f3412fe9e457f95a (diff)
downloadmatterbridge-msglm-7baf386edea4c71919b257d99ca7f7e07897c412.tar.gz
matterbridge-msglm-7baf386edea4c71919b257d99ca7f7e07897c412.tar.bz2
matterbridge-msglm-7baf386edea4c71919b257d99ca7f7e07897c412.zip
Refactor for more flexibility
* Move from gcfg to toml configuration because gcfg was too restrictive * Implemented gateway which has support multiple in and out bridges. * Allow for bridging the same bridges, which means eg you can now bridge between multiple mattermosts. * Support multiple gateways
Diffstat (limited to 'vendor/github.com/BurntSushi/toml/cmd/tomlv/main.go')
-rw-r--r--vendor/github.com/BurntSushi/toml/cmd/tomlv/main.go61
1 files changed, 61 insertions, 0 deletions
diff --git a/vendor/github.com/BurntSushi/toml/cmd/tomlv/main.go b/vendor/github.com/BurntSushi/toml/cmd/tomlv/main.go
new file mode 100644
index 00000000..c7d689a7
--- /dev/null
+++ b/vendor/github.com/BurntSushi/toml/cmd/tomlv/main.go
@@ -0,0 +1,61 @@
+// Command tomlv validates TOML documents and prints each key's type.
+package main
+
+import (
+ "flag"
+ "fmt"
+ "log"
+ "os"
+ "path"
+ "strings"
+ "text/tabwriter"
+
+ "github.com/BurntSushi/toml"
+)
+
+var (
+ flagTypes = false
+)
+
+func init() {
+ log.SetFlags(0)
+
+ flag.BoolVar(&flagTypes, "types", flagTypes,
+ "When set, the types of every defined key will be shown.")
+
+ flag.Usage = usage
+ flag.Parse()
+}
+
+func usage() {
+ log.Printf("Usage: %s toml-file [ toml-file ... ]\n",
+ path.Base(os.Args[0]))
+ flag.PrintDefaults()
+
+ os.Exit(1)
+}
+
+func main() {
+ if flag.NArg() < 1 {
+ flag.Usage()
+ }
+ for _, f := range flag.Args() {
+ var tmp interface{}
+ md, err := toml.DecodeFile(f, &tmp)
+ if err != nil {
+ log.Fatalf("Error in '%s': %s", f, err)
+ }
+ if flagTypes {
+ printTypes(md)
+ }
+ }
+}
+
+func printTypes(md toml.MetaData) {
+ tabw := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
+ for _, key := range md.Keys() {
+ fmt.Fprintf(tabw, "%s%s\t%s\n",
+ strings.Repeat(" ", len(key)-1), key, md.Type(key...))
+ }
+ tabw.Flush()
+}