~pfm/inventory

5dc6be215462fa76edac2b0fa1f4bee74c51e357 — Piotr F. Mieszkowski 2 years ago ca8511a
Introduce line: namespace

- Add words line:empty? and line:dash? to be able to recognize lines that
  carry no information.

- Rename load-line to line:load to keep line-related word names consistent.
1 files changed, 26 insertions(+), 8 deletions(-)

M inventory.retro
M inventory.retro => inventory.retro +26 -8
@@ 120,12 120,28 @@ semicolons.
  '%s_(%s,_%n_days_left) s:format s:put nl ;
~~~

I'd like to skip triple dashes and empty lines just to make the file
more readable.

~~~
'--- 'TIPLE_DASH s:const

:line:empty? (s-f)
  s:length eq? ;

:line:dash? (s-f)
  TIPLE_DASH s:eq? ;
~~~

Each inventory line is either a markdown header (only levels 1 and 2
are supported) or a list item.  Anything else will be ignored.

~~~
:load-line (s-)
  ASCII:SPACE s:split
:line:split (s-ss)
  ASCII:SPACE s:split ;

:line:load (s-)
  line:split
  [ s:trim ] dip
  '#  [ set-section    ] s:case
  '## [ set-subsection ] s:case


@@ 135,16 151,18 @@ are supported) or a list item.  Anything else will be ignored.

The main inventory file defaults to /home/pfm/inw.md.

~~
~~~
'/usr/home/pfm/projects/inw/inw.md 'INVENTORY_FILE s:const

INVENTORY_FILE [ load-line ] file:for-each-line
~~
INVENTORY_FILE
  [ line:load ]
  file:for-each-line
~~~

```
'#_Pasta load-line
'#_Pasta line:load
&Section 'Pasta s:eq? [ 'Loading_sections:_PASS s:put nl ] if

'-_lact.free-milk;_10;_2021.03.10 load-line
'-_oat-milk;_1l;_2021.01.14 load-line
'-_lact.free-milk;_10;_2021.03.10 line:load
'-_oat-milk;_1l;_2021.01.14 line:load
```