Skip to content

Commit

Permalink
Fix all issues with sample code
Browse files Browse the repository at this point in the history
The getopts sample program now compiles and runs. Additionally I made
all of the indentation uniformly four spaces.
  • Loading branch information
Ron Dahlgren committed Jun 9, 2013
1 parent 983269e commit 9e4beaa
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions src/libextra/getopts.rs
Expand Up @@ -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() {
Expand All @@ -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);
Expand Down

9 comments on commit 9e4beaa

@bors
Copy link
Contributor

@bors bors commented on 9e4beaa Jun 10, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on 9e4beaa Jun 10, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging influenza/rust/getopts-doc-update = 9e4beaa into auto

@bors
Copy link
Contributor

@bors bors commented on 9e4beaa Jun 10, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

influenza/rust/getopts-doc-update = 9e4beaa merged ok, testing candidate = 1d914315

@bors
Copy link
Contributor

@bors bors commented on 9e4beaa Jun 10, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on 9e4beaa Jun 11, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on 9e4beaa Jun 11, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging influenza/rust/getopts-doc-update = 9e4beaa into auto

@bors
Copy link
Contributor

@bors bors commented on 9e4beaa Jun 11, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

influenza/rust/getopts-doc-update = 9e4beaa merged ok, testing candidate = d0b1979

@bors
Copy link
Contributor

@bors bors commented on 9e4beaa Jun 11, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on 9e4beaa Jun 11, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding incoming to auto = d0b1979

Please sign in to comment.