commit 7387e0135e7c00626f33d6ddc8b9c2995e8d06e6 parent 9e255cb4b2d49ccf5959763b9988b4e926ddef2c Author: Dmitry Matveyev <dev@greenfork.me> Date: Sat, 3 Jun 2023 12:23:12 +0600 yes: new command Diffstat:
A | yes.ha | | | 23 | +++++++++++++++++++++++ |
1 file changed, 23 insertions(+), 0 deletions(-)
diff --git a/yes.ha b/yes.ha @@ -0,0 +1,23 @@ +use fmt; +use getopt; +use main; +use os; + +export fn utilmain() (main::error | void) = { + const help: []getopt::help = [ + "output a string repeatedly until killed", + "[STRING]", + ]; + const cmd = getopt::parse(os::args, help...); + defer getopt::finish(&cmd); + + const s = if (len(cmd.args) == 1) { + yield cmd.args[0]; + } else { + yield "y"; + }; + + for (true) { + fmt::println(s)!; + }; +};