hare

The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit c34cc1d53b783a960d85892837430dfa90f4885c
parent bc6041a4fbc18f4cc66670109732941c948be1db
Author: Drew DeVault <sir@cmpwn.com>
Date:   Sat, 10 Jul 2021 16:17:53 -0400

cmd/hare: simplify main.ha

Signed-off-by: Drew DeVault <sir@cmpwn.com>

Diffstat:
Mcmd/hare/main.ha | 21++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/cmd/hare/main.ha b/cmd/hare/main.ha @@ -16,14 +16,17 @@ export fn main() void = { getopt::printusage(os::stderr, os::args[0], help...); os::exit(1); }; - if (cmd.args[0] == "build") build(cmd.args) - else if (cmd.args[0] == "cache") cache(cmd.args) - else if (cmd.args[0] == "deps") deps(cmd.args) - else if (cmd.args[0] == "run") run(cmd.args) - else if (cmd.args[0] == "test") test(cmd.args) - else if (cmd.args[0] == "version") version(cmd.args) - else { - getopt::printusage(os::stderr, os::args[0], help...); - os::exit(1); + const task = switch (cmd.args[0]) { + "build" => &build, + "cache" => &cache, + "deps" => &deps, + "run" => &run, + "test" => &test, + "version" => &version, + * => { + getopt::printusage(os::stderr, os::args[0], help...); + os::exit(1); + }, }; + task(cmd.args); };