esv: improve configuration path code

This commit is contained in:
Jeremy Baxter 2024-06-26 09:57:10 +12:00
parent 3507d9ca24
commit 692d413bfa

11
esv.d
View file

@ -108,12 +108,12 @@ config:
configPath = environment.get(cf.configEnv, cf.configPath) configPath = environment.get(cf.configEnv, cf.configPath)
.expandTilde(); .expandTilde();
try { try {
if (cFlag) { if (cFlag)
configPath = cFlag.expandTilde(); configPath = cFlag.expandTilde();
} else {
if (!configPath.exists()) { if (!configPath.exists()) {
mkdirRecurse(dirName(configPath)); mkdirRecurse(dirName(configPath));
configPath.write(format! configPath.write(format!
"## Configuration file for esv. "## Configuration file for esv.
# An API key is required to access the ESV Bible API. # An API key is required to access the ESV Bible API.
@ -127,7 +127,6 @@ key = %s
#passage-references = false #passage-references = false
#verse-numbers = false #verse-numbers = false
"(cf.apiKey)); "(cf.apiKey));
}
} }
readINIFile(ini, configPath); readINIFile(ini, configPath);
} catch (FileException e) { } catch (FileException e) {