fmt.ha (520B)
1 use fmt; 2 use io; 3 4 use util; 5 6 export fn main() void = { 7 const cmd = getopt::parse(os::args, 8 "text formater", 9 ('w', "width", "The max width of output 10 ); 11 defer getopt::finish(&cmd); 12 13 for (let opt .. cmd.opts) { 14 switch (opt.0) { 15 case 'w' => 16 width = strconv::stoi(opt.1)!; 17 case => abort(); 18 }; 19 }; 20 21 let sc = bufio::newscanner(os::stdin); 22 for (true) { 23 let s = match (bufio::scan_str(&sc, " ")) { 24 case let s: str => 25 case io::EOF => break; 26 case => util::die("stdin", "couldn't read"); 27 }; 28 }; 29 };