refactor: canonicalize internal metadata field names
Problem: `pending.Metadata` used shorthand field names (`cat`, `rec`, `rec_mode`) matching user-facing token syntax, coupling internal representation to config. `RecurSpec.from_completion` used a boolean where a `pending.RecurMode` alias exists. `category_syntax` was hardcoded to `'cat'` with no config option. Solution: rename `Metadata` fields to `category`/`recur`/`recur_mode`, add `category_syntax` config option (default `'cat'`), rename `ParsedEntry` fields to match, replace `RecurSpec.from_completion` with `mode: pending.RecurMode`, and restore `[string]` indexer on `pending.ForgeConfig` alongside explicit fields.
This commit is contained in:
parent
4710e6197f
commit
05871fa1a5
12 changed files with 96 additions and 67 deletions
|
|
@ -31,21 +31,21 @@ describe('parse', function()
|
|||
it('extracts category', function()
|
||||
local desc, meta = parse.body('Buy groceries cat:Errands')
|
||||
assert.are.equal('Buy groceries', desc)
|
||||
assert.are.equal('Errands', meta.cat)
|
||||
assert.are.equal('Errands', meta.category)
|
||||
end)
|
||||
|
||||
it('extracts both due and cat', function()
|
||||
local desc, meta = parse.body('Buy milk due:2026-03-15 cat:Errands')
|
||||
assert.are.equal('Buy milk', desc)
|
||||
assert.are.equal('2026-03-15', meta.due)
|
||||
assert.are.equal('Errands', meta.cat)
|
||||
assert.are.equal('Errands', meta.category)
|
||||
end)
|
||||
|
||||
it('extracts metadata in any order', function()
|
||||
local desc, meta = parse.body('Buy milk cat:Errands due:2026-03-15')
|
||||
assert.are.equal('Buy milk', desc)
|
||||
assert.are.equal('2026-03-15', meta.due)
|
||||
assert.are.equal('Errands', meta.cat)
|
||||
assert.are.equal('Errands', meta.category)
|
||||
end)
|
||||
|
||||
it('stops at duplicate key', function()
|
||||
|
|
@ -400,7 +400,7 @@ describe('parse', function()
|
|||
it('detects category prefix', function()
|
||||
local desc, meta = parse.command_add('School: Do homework')
|
||||
assert.are.equal('Do homework', desc)
|
||||
assert.are.equal('School', meta.cat)
|
||||
assert.are.equal('School', meta.category)
|
||||
end)
|
||||
|
||||
it('ignores lowercase prefix', function()
|
||||
|
|
@ -411,7 +411,7 @@ describe('parse', function()
|
|||
it('combines category prefix with inline metadata', function()
|
||||
local desc, meta = parse.command_add('School: Do homework due:2026-03-15')
|
||||
assert.are.equal('Do homework', desc)
|
||||
assert.are.equal('School', meta.cat)
|
||||
assert.are.equal('School', meta.category)
|
||||
assert.are.equal('2026-03-15', meta.due)
|
||||
end)
|
||||
end)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue