42 lines
707 B
Go
42 lines
707 B
Go
// Command burntsushi-tester satisfies BurntSushi's toml-test interface for testing
|
|
// TOML decoders. Namely, it accepts TOML on stdin and outputs JSON on stdout.
|
|
// See: https://github.com/BurntSushi/toml-test
|
|
package main
|
|
|
|
import (
|
|
"flag"
|
|
"fmt"
|
|
"log"
|
|
"os"
|
|
"path"
|
|
|
|
"git.makaay.nl/mauricem/go-toml/parse"
|
|
)
|
|
|
|
func init() {
|
|
log.SetFlags(0)
|
|
|
|
flag.Usage = usage
|
|
flag.Parse()
|
|
}
|
|
|
|
func usage() {
|
|
log.Printf("Usage: %s < <path to TOML-file>\n", path.Base(os.Args[0]))
|
|
flag.PrintDefaults()
|
|
|
|
os.Exit(1)
|
|
}
|
|
|
|
func main() {
|
|
if flag.NArg() != 0 {
|
|
flag.Usage()
|
|
}
|
|
|
|
toml, err := parse.Run(os.Stdin)
|
|
if err != nil {
|
|
log.Fatalf("Error decoding TOML: %s", err)
|
|
} else {
|
|
fmt.Println(toml.MakeSushi())
|
|
}
|
|
}
|