aboutsummaryrefslogtreecommitdiff
path: root/examples/ini.tm
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-09-15 16:42:42 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-09-15 16:42:42 -0400
commit835eb7e89627eea923bfd57bdacba7065c6b1d4c (patch)
tree68fd9832252e728ccf0c7277a5a2f492e41c261c /examples/ini.tm
parentfb37b0ee4253651cab10b41cc2e1f536b17b26d4 (diff)
Add optional:or_exit(...)
Diffstat (limited to 'examples/ini.tm')
-rw-r--r--examples/ini.tm8
1 files changed, 4 insertions, 4 deletions
diff --git a/examples/ini.tm b/examples/ini.tm
index 50668793..afd71a30 100644
--- a/examples/ini.tm
+++ b/examples/ini.tm
@@ -32,13 +32,13 @@ func parse_ini(path:Path)->{Text:{Text:Text}}:
func main(path:Path, key:Text):
keys := key:split($Pattern"/")
if keys.length > 2:
- exit(1, message="
+ exit("
Too many arguments!
$_USAGE
")
if not path:is_file() or path:is_pipe():
- exit(code=1, "Could not read file: $(path.text_content)")
+ exit("Could not read file: $(path.text_content)")
data := parse_ini(path)
if keys.length < 1 or keys[1] == '*':
@@ -47,7 +47,7 @@ func main(path:Path, key:Text):
section := keys[1]:lower()
if not data:has(section):
- exit(1, message="Invalid section name: $section; valid names: $(", ":join([k:quoted() for k in data.keys]))")
+ exit("Invalid section name: $section; valid names: $(", ":join([k:quoted() for k in data.keys]))")
section_data := data:get(section)
if keys.length < 2 or keys[2] == '*':
@@ -56,6 +56,6 @@ func main(path:Path, key:Text):
section_key := keys[2]:lower()
if not section_data:has(section_key):
- exit(1, message="Invalid key: $section_key; valid keys: $(", ":join(section_data.keys))")
+ exit("Invalid key: $section_key; valid keys: $(", ":join(section_data.keys))")
say(section_data:get(section_key))