Fixes for ask() being optional and command success status
This commit is contained in:
parent
b468ee67f2
commit
c153e05258
@ -585,7 +585,7 @@ env_t *global_env(void)
|
|||||||
{"random", "default_rng", "RNG"},
|
{"random", "default_rng", "RNG"},
|
||||||
{"say", "say", "func(text:Text, newline=yes)"},
|
{"say", "say", "func(text:Text, newline=yes)"},
|
||||||
{"print", "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)"},
|
{"exit", "tomo_exit", "func(message=none:Text, code=Int32(1) -> Abort)"},
|
||||||
{"fail", "fail_text", "func(message:Text -> Abort)"},
|
{"fail", "fail_text", "func(message:Text -> Abort)"},
|
||||||
{"sleep", "sleep_num", "func(seconds:Num)"},
|
{"sleep", "sleep_num", "func(seconds:Num)"},
|
||||||
|
@ -33,6 +33,12 @@ struct ProgramResult(stdout:[Byte], stderr:[Byte], exit_type:ExitType):
|
|||||||
else: return none
|
else: return none
|
||||||
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}):
|
struct Command(command:Text, args=[:Text], env={:Text,Text}):
|
||||||
func from_path(path:Path, args=[:Text], env={:Text,Text} -> Command):
|
func from_path(path:Path, args=[:Text], env={:Text,Text} -> Command):
|
||||||
return Command(Text(path), args, env)
|
return Command(Text(path), args, env)
|
||||||
|
@ -646,7 +646,7 @@ public _Noreturn void tomo_exit(Text_t text, int32_t status)
|
|||||||
_exit(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;
|
OptionalText_t ret = NONE_TEXT;
|
||||||
FILE *out = stdout;
|
FILE *out = stdout;
|
||||||
|
Loading…
Reference in New Issue
Block a user