cmd/revid-cli: move creation code to near call site

This commit is contained in:
Dan Kortschak 2018-06-08 22:26:20 +09:30
parent f5a3899e1d
commit e2c2093e28
1 changed files with 14 additions and 14 deletions

View File

@ -332,6 +332,20 @@ func startRevid() {
revidInst.Start()
}
func createRevidInstance() {
// Try to create the revid instance with the given config
var err error
for revidInst, err = revid.NewRevid(config); err != nil; {
// If the config does have a logger, use it to output error, otherwise
// just output to std output
if config.Logger != nil {
config.Logger.Log(progName, "FATAL ERROR", err.Error())
} else {
fmt.Printf("FATAL ERROR: %v", err.Error())
}
}
}
func stopRevid() {
revidInst.Stop()
@ -467,17 +481,3 @@ func revidReportActions(pin int) (int, error) {
return -1, errors.New("External pin" + strconv.Itoa(pin) + " not defined")
}
}
func createRevidInstance() {
// Try to create the revid instance with the given config
var err error
for revidInst, err = revid.NewRevid(config); err != nil; {
// If the config does have a logger, use it to output error, otherwise
// just output to std output
if config.Logger != nil {
config.Logger.Log(progName, "FATAL ERROR", err.Error())
} else {
fmt.Printf("FATAL ERROR: %v", err.Error())
}
}
}