diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-09-15 16:42:42 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-09-15 16:42:42 -0400 |
| commit | 835eb7e89627eea923bfd57bdacba7065c6b1d4c (patch) | |
| tree | 68fd9832252e728ccf0c7277a5a2f492e41c261c /examples | |
| parent | fb37b0ee4253651cab10b41cc2e1f536b17b26d4 (diff) | |
Add optional:or_exit(...)
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/game/game.tm | 4 | ||||
| -rw-r--r-- | examples/ini.tm | 8 | ||||
| -rw-r--r-- | examples/tomodeps.tm | 2 |
3 files changed, 6 insertions, 8 deletions
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 ") |
