John Smith commited on 2022-127 00:13:20
Showing 1 changed files, with 16 additions and 0 deletions.
Memoire will now load a table of settings from ~/.config/memoire/config.rec Nothing hinges on these settings, but that will change in future updates.
| ... | ... |
@@ -8,6 +8,7 @@ local SRC_DIR = arg[0]:match("^.*/") or ""
|
| 8 | 8 |
local Prompt = dofile(SRC_DIR .. "prompt.lua") |
| 9 | 9 |
local review = dofile(SRC_DIR .. "review.lua") |
| 10 | 10 |
local loader = dofile(SRC_DIR .. "loader.lua") |
| 11 |
+local recrw = dofile(SRC_DIR .. "recrw.lua") |
|
| 11 | 12 |
|
| 12 | 13 |
--[[ |
| 13 | 14 |
gets the score (again/hard/good/easy/correction) from a string by first character |
| ... | ... |
@@ -124,6 +125,21 @@ else |
| 124 | 125 |
action = "h" |
| 125 | 126 |
end |
| 126 | 127 |
|
| 128 |
+-- load settings from config Recfile |
|
| 129 |
+local confdir = os.getenv("HOME") .. "/.config/memoire/"
|
|
| 130 |
+local config = { DeckFile = { "" } }
|
|
| 131 |
+do |
|
| 132 |
+local fh = io.open(confdir .. "config.rec") |
|
| 133 |
+if ft then |
|
| 134 |
+ local ft = fh:read("a")
|
|
| 135 |
+ local ct = recrw.read(ft) |
|
| 136 |
+ if ct and ct[1] then config = ct[1] |
|
| 137 |
+ else io.write("Erroneous configuration file\n") end
|
|
| 138 |
+else |
|
| 139 |
+ io.write("Could not open configuration file in " .. confdir .. "\n")
|
|
| 140 |
+end |
|
| 141 |
+end |
|
| 142 |
+ |
|
| 127 | 143 |
local deckfname = "example.rec" |
| 128 | 144 |
if arg[2] then |
| 129 | 145 |
deckfname = arg[2] |
| 130 | 146 |