diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-01-12 16:54:37 -0500 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-01-12 16:54:37 -0500 |
| commit | c60ea2079fb230213308904cd0966e5481d2d994 (patch) | |
| tree | 630bcb480bfcdd2dc4aec5ecb4a2f8d1daa6475a /examples/ini | |
| parent | 645d66e0de0f201404d9ad4b210f90c139a247ff (diff) | |
Fix up examples
Diffstat (limited to 'examples/ini')
| -rw-r--r-- | examples/ini/ini.tm | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/examples/ini/ini.tm b/examples/ini/ini.tm index 9575b9fd..46c25860 100644 --- a/examples/ini/ini.tm +++ b/examples/ini/ini.tm @@ -6,10 +6,10 @@ _HELP := " $_USAGE " -func parse_ini(path:Path -> {Text:{Text:Text}}): +func parse_ini(path:Path -> {Text,{Text,Text}}): text := path:read() or exit("Could not read INI file: $\[31;1]$(path.text_content)$\[]") - sections := @{:Text:@{Text:Text}} - current_section := @{:Text:Text} + sections := @{:Text,@{Text,Text}} + current_section := @{:Text,Text} # Line wraps: text = text:replace($/\{1 nl}{0+space}/, " ") @@ -19,14 +19,14 @@ func parse_ini(path:Path -> {Text:{Text:Text}}): skip if line:starts_with(";") or line:starts_with("#") if line:matches($/[?]/): section_name := line:replace($/[?]/, "\1"):trim():lower() - current_section = @{:Text:Text} + current_section = @{:Text,Text} sections[section_name] = current_section else if line:matches($/{..}={..}/): key := line:replace($/{..}={..}/, "\1"):trim():lower() value := line:replace($/{..}={..}/, "\2"):trim() current_section[key] = value - return {k:v[] for k,v in sections[]} + return {k=v[] for k,v in sections[]} func main(path:Path, key:Text?): keys := (key or ""):split($|/|) |
