diff options
author | Kartik Agaram <vc@akkartik.com> | 2020-09-16 09:26:38 -0700 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2020-09-16 09:26:38 -0700 |
commit | fecb649b9ac20397f8eec017be63864db4e571bb (patch) | |
tree | df9f39d0f909abec0ca227e37cbdb2690822571c /apps | |
parent | 1f2ebeb44f3b0ddf93d7955378b829f2b7b6c2c7 (diff) | |
download | mu-fecb649b9ac20397f8eec017be63864db4e571bb.tar.gz |
6787
Diffstat (limited to 'apps')
-rw-r--r-- | apps/tile/main.mu | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/apps/tile/main.mu b/apps/tile/main.mu index d6dad159..9a83ed5a 100644 --- a/apps/tile/main.mu +++ b/apps/tile/main.mu @@ -1,3 +1,34 @@ -fn main -> exit-status/ebx: int { - run-tests +fn main args-on-stack: (addr array addr array byte) -> exit-status/ebx: int { + var args/eax: (addr array addr array byte) <- copy args-on-stack + var len/ecx: int <- length args + $main-body: { + # if no args, run in interactive mode + compare len, 1 + { + break-if-> + exit-status <- interactive args-on-stack + break $main-body + } + # else if single arg is 'test', run tests + compare len, 2 + { + break-if-!= + var tmp/ecx: (addr addr array byte) <- index args, 1 + var tmp2/eax: boolean <- string-equal? *tmp, "test" + compare tmp2, 0 + { + break-if-= + run-tests + exit-status <- copy 0 # TODO: get at Num-test-failures somehow + break $main-body + } + } + # otherwise error message + print-string-to-real-screen "usage: tile\n" + print-string-to-real-screen " or tile test\n" + exit-status <- copy 1 + } +} + +fn interactive args: (addr array addr array byte) -> exit-status/ebx: int { } |