Compare commits

...

2 Commits
1.0.13 ... main

Author SHA1 Message Date
c00be8c1fc Add asdf tool-versions definitions pinning this to Nim 1.6 2024-05-10 11:59:58 -05:00
96ee649bf6 Change the logic around how we load our config.
The previous logic that was intended to find the first non-empty
filename that represented a valid file location was wrong. Replaced with
a simpler filter-based version.

Additionally, if the user provides a specific configuration filename, we
no longer fall back to the defaults if it is not found. Instead we just
err out and inform them that the file the specified was not found.
2022-04-02 08:45:30 -05:00
4 changed files with 11 additions and 17 deletions

1
.tool-versions Normal file
View File

@ -0,0 +1 @@
nim 1.6.20

View File

@ -1 +1 @@
const PTK_VERSION* = "1.0.13"
const PTK_VERSION* = "1.0.14"

23
ptk.nim
View File

@ -307,28 +307,21 @@ Options:
quit()
# Find and parse the .ptkrc file
let ptkrcLocations = @[
if args["--config"]: $args["--config"] else:"",
".ptkrc", $getEnv("PTKRC"), $getEnv("HOME") & "/.ptkrc"]
let ptkrcLocations =
if args["--config"]: @[$args["--config"]]
else: @[".ptkrc", $getEnv("PTKRC"), $getEnv("HOME") & "/.ptkrc"]
var ptkrcFilename: string =
foldl(ptkrcLocations, if len(a) > 0: a elif fileExists(b): b else: "")
let foundPtkrcLocations =
ptkrcLocations.filterIt(it.len > 0 and fileExists(it))
var cfg: JsonNode
var cfgFile: File
if not fileExists(ptkrcFilename):
if foundPtkrcLocations.len < 1:
warn "ptk: could not find .ptkrc file."
debug "ptk: considered the following locations:\n\t" & ptkrcLocations.join("\n\t")
#ptkrcFilename = $getEnv("HOME") & "/.ptkrc"
#try:
# cfgFile = open(ptkrcFilename, fmWrite)
# cfgFile.write("{\"timelineLogFile\": \"timeline.log.json\"}")
#except: warn "ptk: could not write default .ptkrc to " & ptkrcFilename
#finally: close(cfgFile)
try: cfg = parseFile(ptkrcFilename)
try: cfg = parseFile(foundPtkrcLocations[0])
except: raise newException(IOError,
"unable to read config file: " & ptkrcFilename &
"unable to read config file: " & foundPtkrcLocations[0] &
"\x0D\x0A" & getCurrentExceptionMsg())
# Find the time log file

View File

@ -1,6 +1,6 @@
# Package
version = "1.0.13"
version = "1.0.14"
author = "Jonathan Bernard"
description = "Personal Time Keeper"
license = "MIT"