hautils

[hare] Set of POSIX utilities
Log | Files | Refs | README | LICENSE

yes.ha (385B)


      1 use fmt;
      2 use getopt;
      3 use main;
      4 use os;
      5 
      6 export fn utilmain() (main::error | void) = {
      7 	const help: []getopt::help = [
      8 		"output a string repeatedly until killed",
      9 		"[STRING]",
     10 	];
     11 	const cmd = getopt::parse(os::args, help...);
     12 	defer getopt::finish(&cmd);
     13 
     14 	const s = if (len(cmd.args) == 1) {
     15 		yield cmd.args[0];
     16 	} else {
     17 		yield "y";
     18 	};
     19 
     20 	for (true) {
     21 		fmt::println(s)!;
     22 	};
     23 };