Skip to content

Instantly share code, notes, and snippets.

@mcandre
Created February 13, 2012 22:29
Show Gist options
  • Save mcandre/1821006 to your computer and use it in GitHub Desktop.
Save mcandre/1821006 to your computer and use it in GitHub Desktop.
fn main(args: [str]) {
let opts = [
optopt("o"),
optflag("h"),
optflag("help")
];
let match = alt getopts(vec::shift(args), opts) {
ok(m) { m }
err(f) { fail fail_str(f) }
};
if opt_present(match, "h") || opt_present(match, "help") {
print_usage();
ret;
}
let output = opt_maybe_str(match, "o");
let input = if !vec::is_empty(match.free) {
match.free[0]
} else {
print_usage();
ret;
}
do_work(input, output);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment