Fix all issues with sample code

The getopts sample program now compiles and runs. Additionally I made
all of the indentation uniformly four spaces.
This commit is contained in:
Ron Dahlgren 2013-06-09 16:13:52 -07:00
parent 983269e71a
commit 9e4beaac9d

View file

@ -33,19 +33,20 @@
* ```
* extern mod extra;
* use extra::getopts::*;
* use std::os;
*
* fn do_work(in: &str, out: Option<~str>) {
* io::println(in);
* io::println(match out {
* Some(x) => x,
* None => ~"No Output"
* });
* println(in);
* println(match out {
* Some(x) => x,
* None => ~"No Output"
* });
* }
*
* fn print_usage(program: &str, _opts: &[extra::getopts::Opt]) {
* io::println(fmt!("Usage: %s [options]", program));
* io::println("-o\t\tOutput");
* io::println("-h --help\tUsage");
* fn print_usage(program: &str, _opts: &[Opt]) {
* println(fmt!("Usage: %s [options]", program));
* println("-o\t\tOutput");
* println("-h --help\tUsage");
* }
*
* fn main() {
@ -58,9 +59,9 @@
* optflag("h"),
* optflag("help")
* ];
* let matches = match getopts(vec::tail(args), opts) {
* result::Ok(m) => { m }
* result::Err(f) => { fail!(fail_str(f)) }
* let matches = match getopts(args.tail(), opts) {
* Ok(m) => { m }
* Err(f) => { fail!(fail_str(f)) }
* };
* if opt_present(&matches, "h") || opt_present(&matches, "help") {
* print_usage(program, opts);