sleep.ha (527B)
1 use getopt; 2 use main; 3 use os; 4 use strconv; 5 use time; 6 7 export fn utilmain() (void | main::error) = { 8 const help: [_]getopt::help = [ 9 "suspend execution for an interval", 10 "<seconds>", 11 ]; 12 const cmd = getopt::parse(os::args, help...); 13 defer getopt::finish(&cmd); 14 15 if (len(cmd.args) != 1) { 16 main::usage(help); 17 }; 18 19 const seconds = match (strconv::stou(cmd.args[0])) { 20 case (strconv::invalid | strconv::overflow) => 21 main::usage(help); 22 case let s: uint => 23 yield s: int; 24 }; 25 26 time::sleep(seconds * time::SECOND); 27 };