diff options
Diffstat (limited to 'doProto.go')
| -rw-r--r-- | doProto.go | 38 | 
1 files changed, 18 insertions, 20 deletions
@@ -23,7 +23,6 @@ import (  	"github.com/go-cmd/cmd"  	"go.wit.com/lib/fhelp"  	"go.wit.com/lib/gui/shell" -	"go.wit.com/lib/protobuf/argvpb"  	"go.wit.com/log"  ) @@ -37,25 +36,24 @@ func doProto(argvProto string) (string, error) {  	if argv.Clean != nil {  		doClean(pf.Filebase) -		argvpb.GoodExit("doClean() ran") +		return "doClean() ran", nil  	}  	if argv.Mtime {  		doMtime(pf.Filebase) -		argvpb.GoodExit("doClean() ran") +		return "doClean() ran", nil  	}  	if argv.ReFormat {  		protoReformatComments(argvProto)  		// time.Sleep(5 * time.Second)  		protoReformat(argvProto) -		log.Info("format done") -		okExit("") +		return "format done", nil  	}  	if argv.Comments {  		protoReformatComments(argvProto) -		okExit("") +		return "comments ok?", nil  	}  	if argv.Regret { @@ -64,7 +62,7 @@ func doProto(argvProto string) (string, error) {  	}  	if doMtime(pf.Filebase) { -		argvpb.GoodExit(pf.Filename + " did not change") +		return pf.Filename + " did not change", nil  	} else {  		log.Info("ctime check: need to re-run autogenpb")  	} @@ -74,7 +72,7 @@ func doProto(argvProto string) (string, error) {  	// for `autogenpb: ` lines  	if err := pf.protoParse(); err != nil {  		log.Info("autogenpb parse error:", err) -		badExit(err) +		return "autogenpb parse error", err  	}  	if !argv.NoFormat { @@ -82,17 +80,17 @@ func doProto(argvProto string) (string, error) {  	}  	if pf.Bases == nil { -		badExit(fmt.Errorf("Base was nil. 'message %s {` did not exist", pf.Filebase)) +		return "pf.Bases == nil", fmt.Errorf("Base was nil. 'message %s {` did not exist", pf.Filebase)  	}  	if pf.Base == nil { -		badExit(fmt.Errorf("Base was nil. 'message %s {` did not exist", pf.Filebase)) +		return "pf.Base == nil", fmt.Errorf("Base was nil. 'message %s {` did not exist", pf.Filebase)  	}  	// if you have gotten here, at least the .proto buf file is OK  	if argv.DryRun {  		// show the protobuf of the protobuf. It's like Inception  		pf.printMsgTable() -		okExit("") +		return "DryRun", nil  	}  	// todo, look for go.work files @@ -147,21 +145,21 @@ func doProto(argvProto string) (string, error) {  	// checkCmd("protoc-gen-go")  	if !fhelp.CheckProtoc() { -		badExit(fmt.Errorf("you do not have 'protoc' installed")) +		return "protoc missing", fmt.Errorf("you do not have 'protoc' installed")  	}  	pf.Pbfilename = pf.Filebase + ".pb.go"  	// try to create the foo.pb.go file using protoc if it is not there  	if !shell.Exists(pf.Pbfilename) {  		if !fhelp.CheckProtoc() { -			badExit(fmt.Errorf("you do not have 'protoc' installed")) +			return "protoc missing", fmt.Errorf("you do not have 'protoc' installed")  		}  		// checkCmd("protoc")  		// checkCmd("protoc-gen-go")  		if err := me.pb.protocBuild(pf); err != nil { -			badExit(err) +			return "protoc failed", err  		}  	} @@ -169,13 +167,13 @@ func doProto(argvProto string) (string, error) {  	// try to add the Mutex to the pb.go file  	if err := me.pb.addMutex(pf); err != nil { -		badExit(err) +		return "addMutex(pf) failed", err  	}  	// if foo.pb.go still doesn't exist, protoc failed  	if !shell.Exists(pf.Pbfilename) { -		log.Info("protoc build error.", pf.Pbfilename) -		badExit(errors.New("failed to be created with protoc and proto-gen-go")) +		s := "protoc build error " + pf.Pbfilename +		return s, errors.New("failed to be created with protoc and proto-gen-go")  	}  	// make the marshal.pb.go file @@ -183,18 +181,18 @@ func doProto(argvProto string) (string, error) {  	// make the sort.pb.go file  	if err := me.pb.makeNewSortfile(pf); err != nil { -		badExit(err) +		return "makeNewSortfile(pf)", err  	}  	if pf.DoGui {  		if err := me.pb.makeGuiFile(pf); err != nil { -			badExit(err) +			return "makeGuiFile(pf)", err  		}  	}  	if pf.DoHTTP {  		if err := me.pb.makeHTTPFile(pf); err != nil { -			badExit(err) +			return "makeHTTPFile(pf)", err  		}  	}  	var err error  | 
