Serge Bazanski | 8d7843c | 2018-10-04 10:37:36 +0100 | [diff] [blame] | 1 | package main |
| 2 | |
| 3 | import ( |
| 4 | "flag" |
| 5 | "io/ioutil" |
| 6 | |
| 7 | "github.com/golang/glog" |
| 8 | "github.com/golang/protobuf/proto" |
| 9 | |
| 10 | confpb "code.hackerspace.pl/q3k/topo/proto/config" |
| 11 | ) |
| 12 | |
| 13 | var ( |
| 14 | flagConfigPath string |
| 15 | ) |
| 16 | |
| 17 | func init() { |
| 18 | flag.Set("logtostderr", "true") |
| 19 | } |
| 20 | |
| 21 | func main() { |
| 22 | flag.StringVar(&flagConfigPath, "config_path", "./topo.pb.text", "Text proto configuration of Topo (per config.proto)") |
| 23 | flag.Parse() |
| 24 | |
| 25 | data, err := ioutil.ReadFile(flagConfigPath) |
| 26 | if err != nil { |
| 27 | glog.Exitf("Could not read config: %v", err) |
| 28 | } |
| 29 | |
| 30 | config := confpb.Config{} |
| 31 | proto.UnmarshalText(string(data), &config) |
| 32 | glog.Infof("%+v", config) |
| 33 | } |