From 835eb7e89627eea923bfd57bdacba7065c6b1d4c Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sun, 15 Sep 2024 16:42:42 -0400 Subject: Add optional:or_exit(...) --- examples/game/game.tm | 4 +--- examples/ini.tm | 8 ++++---- examples/tomodeps.tm | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) (limited to 'examples') diff --git a/examples/game/game.tm b/examples/game/game.tm index c7020f55..8c5124d0 100644 --- a/examples/game/game.tm +++ b/examples/game/game.tm @@ -9,9 +9,7 @@ func main(map=(./map.txt)): extern InitWindow:func(w:Int32, h:Int32, title:CString)->Void InitWindow(1600, 900, "raylib [core] example - 2d camera") - map_contents := if contents := map:read(): - contents - else: exit(code=1, "Could not find the game map: $map") + map_contents := map:read():or_exit("Could not find the game map: $map") World.CURRENT:load_map(map_contents) 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)) diff --git a/examples/tomodeps.tm b/examples/tomodeps.tm index 209f14e0..a427c5f9 100644 --- a/examples/tomodeps.tm +++ b/examples/tomodeps.tm @@ -103,7 +103,7 @@ func draw_tree(dep:Dependency, dependencies:{Dependency:{Dependency}}): func main(files:[Text]): if files.length == 0: - exit(1, message=" + exit(" Please provide at least one file! $_USAGE ") -- cgit v1.2.3