aboutsummaryrefslogtreecommitdiff
path: root/examples/ini/ini.tm
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-09-16 16:06:19 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-09-16 16:06:19 -0400
commitde49bc5bb3198f450cb367085f9def0d89782258 (patch)
treea81354271bd3de567a7656807416cd5c69e4b08b /examples/ini/ini.tm
parent821bde156c222c7384c67517d773dc14a03342e7 (diff)
Deprecate :or_else()/:or_fail()/:or_exit() in favor of the `or` operator
Diffstat (limited to 'examples/ini/ini.tm')
-rw-r--r--examples/ini/ini.tm8
1 files changed, 4 insertions, 4 deletions
diff --git a/examples/ini/ini.tm b/examples/ini/ini.tm
index 8b91d3fa..37692cae 100644
--- a/examples/ini/ini.tm
+++ b/examples/ini/ini.tm
@@ -7,7 +7,7 @@ _HELP := "
"
func parse_ini(path:Path)->{Text:{Text:Text}}:
- text := path:read():or_exit("Could not read INI file: $\[31;1]$(path.text_content)$\[]")
+ text := path:read() or exit("Could not read INI file: $\[31;1]$(path.text_content)$\[]")
sections := {:Text:@{Text:Text}}
current_section := @{:Text:Text}
@@ -29,7 +29,7 @@ func parse_ini(path:Path)->{Text:{Text:Text}}:
return {k:v[] for k,v in sections}
func main(path:Path, key:Text?):
- keys := key:or_else(""):split($|/|)
+ keys := (key or ""):split($|/|)
if keys.length > 2:
exit("
Too many arguments!
@@ -42,7 +42,7 @@ func main(path:Path, key:Text?):
return
section := keys[1]:lower()
- section_data := data:get(section):or_exit("
+ section_data := data:get(section) or exit("
Invalid section name: $\[31;1]$section$\[]
Valid names: $\[1]$(", ":join([k:quoted() for k in data.keys]))$\[]
")
@@ -51,7 +51,7 @@ func main(path:Path, key:Text?):
return
section_key := keys[2]:lower()
- value := section_data:get(section_key):or_exit("
+ value := section_data:get(section_key) or exit("
Invalid key: $\[31;1]$section_key$\[]
Valid keys: $\[1]$(", ":join([s:quoted() for s in section_data.keys]))$\[]
")