diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-03-21 18:07:17 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-03-21 18:07:17 -0400 |
| commit | c153e052583fecc39f2cac9c40f99218e2e70c41 (patch) | |
| tree | 7f570bddbe3147ddcba3086a598eef59ca0ee3a0 | |
| parent | b468ee67f21570d278f80d569eca8ee4149fb7cd (diff) | |
Fixes for ask() being optional and command success status
| -rw-r--r-- | environment.c | 2 | ||||
| -rw-r--r-- | examples/commands/commands.tm | 6 | ||||
| -rw-r--r-- | stdlib/stdlib.c | 2 |
3 files changed, 8 insertions, 2 deletions
diff --git a/environment.c b/environment.c index 9f230cd0..85677524 100644 --- a/environment.c +++ b/environment.c @@ -585,7 +585,7 @@ env_t *global_env(void) {"random", "default_rng", "RNG"}, {"say", "say", "func(text:Text, newline=yes)"}, {"print", "say", "func(text:Text, newline=yes)"}, - {"ask", "ask", "func(prompt:Text, bold=yes, force_tty=yes -> Text)"}, + {"ask", "ask", "func(prompt:Text, bold=yes, force_tty=yes -> Text?)"}, {"exit", "tomo_exit", "func(message=none:Text, code=Int32(1) -> Abort)"}, {"fail", "fail_text", "func(message:Text -> Abort)"}, {"sleep", "sleep_num", "func(seconds:Num)"}, diff --git a/examples/commands/commands.tm b/examples/commands/commands.tm index c70d8592..7d2f4a6f 100644 --- a/examples/commands/commands.tm +++ b/examples/commands/commands.tm @@ -33,6 +33,12 @@ struct ProgramResult(stdout:[Byte], stderr:[Byte], exit_type:ExitType): else: return none return none + func succeeded(r:ProgramResult -> Bool): + when r.exit_type is Exited(status): + return (status == 0) + else: + return no + struct Command(command:Text, args=[:Text], env={:Text,Text}): func from_path(path:Path, args=[:Text], env={:Text,Text} -> Command): return Command(Text(path), args, env) diff --git a/stdlib/stdlib.c b/stdlib/stdlib.c index 9103e4dd..d09488d0 100644 --- a/stdlib/stdlib.c +++ b/stdlib/stdlib.c @@ -646,7 +646,7 @@ public _Noreturn void tomo_exit(Text_t text, int32_t status) _exit(status); } -public Text_t ask(Text_t prompt, bool bold, bool force_tty) +public OptionalText_t ask(Text_t prompt, bool bold, bool force_tty) { OptionalText_t ret = NONE_TEXT; FILE *out = stdout; |
