suppress error if configuration file not exists

This commit is contained in:
Gokcehan 2016-08-17 22:35:18 +03:00
parent 09ebc54d20
commit 2f224240bf

View File

@ -29,22 +29,26 @@ func client() {
nav := newNav(ui.wins[0].h) nav := newNav(ui.wins[0].h)
app := &App{ui, nav} app := &App{ui, nav}
rcFile, err := os.Open(gConfigPath) if _, err := os.Stat(gConfigPath); err == nil {
if err != nil { log.Printf("reading configuration file: %s", gConfigPath)
msg := fmt.Sprintf("opening configuration file: %s", err)
app.ui.message = msg
log.Printf(msg)
} else {
app.ui.echoFileInfo(app.nav)
}
defer rcFile.Close()
p := newParser(rcFile) rcFile, err := os.Open(gConfigPath)
for p.parse() { if err != nil {
p.expr.eval(app, nil) msg := fmt.Sprintf("opening configuration file: %s", err)
} app.ui.message = msg
log.Printf(msg)
} else {
app.ui.echoFileInfo(app.nav)
}
defer rcFile.Close()
// TODO: parser error check p := newParser(rcFile)
for p.parse() {
p.expr.eval(app, nil)
}
// TODO: parser error check
}
app.ui.draw(app.nav) app.ui.draw(app.nav)