Skip to content

Commit abbf780

Browse files
committed
Implement Config.errors.unexpected_key
Fix zettelkasten example
1 parent 651c34a commit abbf780

23 files changed

Lines changed: 68 additions & 57 deletions

core/config.lua

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@ Config.errors = {
9090
.. "ROOT"
9191
.. " as the name of a note type in `config.note_schema`."
9292
end,
93+
94+
--- @param key string
95+
unexpected_key = function(key)
96+
return "Unexpected key " .. key .. " in config."
97+
end
9398
}
9499

95100
--- @param config_table PartialConfigTable
@@ -99,6 +104,7 @@ function Config:new(config_table)
99104
--- @cast self Config
100105
setmetatable(self, Config)
101106
local err = validate.types("Config:new", {
107+
{ config_table, "table", "config_table" },
102108
{ config_table.note_schema, "table?", "note_schema" },
103109
{ config_table.resolve_path, "function?", "resolve_path" },
104110
{ config_table.transform_lines, "function?", "transform_lines" },
@@ -117,6 +123,11 @@ function Config:new(config_table)
117123
if err then
118124
return nil, err
119125
end
126+
for key, _ in pairs(config_table) do
127+
if default_config[key] == nil then
128+
return nil, Config.errors.unexpected_key(key)
129+
end
130+
end
120131
local note_schema = config_table.note_schema or default_config.note_schema
121132
for i, note_type in ipairs(note_schema) do
122133
local curr_string = "config_table.note_schema[" .. i .. "]"

examples/zettelkasten/configs.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ local configs = {
77
note_schema = {
88
{ "prm", "%p ", "%%" },
99
{ "ref", "%r ", "%%" },
10-
{ "tdo", "%t", "%%" },
10+
{ "tdo", "%t ", "%%" },
1111
{ "quo", "%q ", "%%" },
1212
{ "flt", "%f ", "%%" },
1313
{ "qst", "%? ", "%%" },

examples/zettelkasten/output/flt/17363939900.md

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Book is mainly focused on investor philosophies and thought patterns.
2+
3+
4+
Tags: #investing #the-intelligent-investor
5+
From: [[ref/17364552361.md|Introduction]]

examples/zettelkasten/output/flt/17363939901.md renamed to examples/zettelkasten/output/flt/17364552361.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33

44
Tags: #investing #the-intelligent-investor #predictions
5-
From: [[ref/17363939901.md|Introduction]]
5+
From: [[ref/17364552361.md|Introduction]]
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Have not found one person that's consistently made a profit by "following the market".
22

33

4-
Tags: #the-intelligent-investor #investing
5-
From: [[ref/17363939901.md|Introduction]]
4+
Tags: #investing #the-intelligent-investor
5+
From: [[ref/17364552361.md|Introduction]]

examples/zettelkasten/output/flt/17363939903.md renamed to examples/zettelkasten/output/flt/17364552363.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ and choose the companies in those industries that look the most promising.
33

44

55
Tags: #investing #the-intelligent-investor #key-idea
6-
From: [[ref/17363939901.md|Introduction]]
6+
From: [[ref/17364552361.md|Introduction]]
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
[[prm/17363939900.md|The Intelligent Investor]]
1+
[[prm/17364552360.md|The Intelligent Investor]]

examples/zettelkasten/output/prm/17363939900.md

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# The Intelligent Investor
2+
[[ref/17364552360.md|Preface]]
3+
[[ref/17364552361.md|Introduction]]
4+
[[ref/17364552362.md|Chapter 1]]
5+
Source: [[src/17364552360.md|The Intelligent Investor]]
6+
7+
8+
Tags: #investing #the-intelligent-investor

0 commit comments

Comments
 (0)