2016-12-13 17:56:45 +00:00
|
|
|
// +build ignore
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
2016-12-13 19:02:39 +00:00
|
|
|
"flag"
|
2016-12-13 17:56:45 +00:00
|
|
|
"log"
|
|
|
|
"os"
|
|
|
|
"text/template"
|
2016-12-13 19:02:39 +00:00
|
|
|
|
|
|
|
"github.com/vbatts/emojisum/emoji"
|
2016-12-13 17:56:45 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2016-12-13 19:02:39 +00:00
|
|
|
flag.Parse()
|
|
|
|
input, err := os.Open(*flInput)
|
2016-12-13 17:56:45 +00:00
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
defer input.Close()
|
|
|
|
|
2016-12-13 19:02:39 +00:00
|
|
|
vm := emoji.VersionedMap{}
|
2016-12-13 17:56:45 +00:00
|
|
|
|
|
|
|
dec := json.NewDecoder(input)
|
2016-12-13 19:02:39 +00:00
|
|
|
if err := dec.Decode(&vm); err != nil {
|
2016-12-13 17:56:45 +00:00
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2016-12-13 19:02:39 +00:00
|
|
|
output, err := os.Create(*flOutput)
|
2016-12-13 17:56:45 +00:00
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
defer output.Close()
|
2016-12-13 19:02:39 +00:00
|
|
|
|
|
|
|
mapGoTemp := template.Must(template.ParseFiles(*flTemplate))
|
|
|
|
if err := mapGoTemp.Execute(output, vm); err != nil {
|
2016-12-13 17:56:45 +00:00
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var (
|
2016-12-13 19:02:39 +00:00
|
|
|
flInput = flag.String("in", "emojimap.json", "json input")
|
|
|
|
flOutput = flag.String("out", "map_gen.go", "golang output")
|
|
|
|
flTemplate = flag.String("template", "map_gen.tmpl", "template of golang source to use")
|
2016-12-13 17:56:45 +00:00
|
|
|
)
|