diff options
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 22 |
1 files changed, 20 insertions, 2 deletions
@@ -21,7 +21,23 @@ func main() { // for very new users or users unfamilar with the command line, this may help them if argv.Base == "help" || argv.Base == "?" { pp.WriteHelp(os.Stdout) - os.Exit(0) + os.Exit(-1) + } + + // you need a proto file + if argv.Proto == "" { + log.Info("you must provide --proto <filename>") + os.Exit(-1) + } + + if !shell.Exists(argv.Proto) { + log.Info("protobuf", argv.Proto, "is missing") + os.Exit(-1) + } + + if ! strings.HasSuffix(argv.Proto, ".proto") { + log.Info("protobuf", argv.Proto, "must end in .proto") + os.Exit(-1) } cmd := []string{"go", "list", "-f", "'{{.Name}}'"} @@ -32,7 +48,9 @@ func main() { packageName = strings.Trim(packageName, "'") log.Info("packageName == ", packageName) - f, _ := os.OpenFile("test.sort.pb.go", os.O_WRONLY|os.O_CREATE, 0600) + protobase := strings.TrimSuffix(argv.Proto, ".proto") + + f, _ := os.OpenFile(protobase + ".sort.pb.go", os.O_WRONLY|os.O_CREATE, 0600) sortmap := make(map[string]string) sortmap["package"] = packageName |
