Remove vecs from std::getopts
This commit is contained in:
parent
8840fab822
commit
5f71a204d3
@ -334,7 +334,6 @@ fn build_session_options(binary: str, match: getopts::match, binary_dir: str)
|
||||
let static = opt_present(match, "static");
|
||||
|
||||
let library_search_paths = ~[binary_dir + "/lib"];
|
||||
// FIXME: Remove this vec->ivec conversion.
|
||||
let lsp_vec = getopts::opt_strs(match, "L");
|
||||
for lsp: str in lsp_vec { library_search_paths += ~[lsp]; }
|
||||
|
||||
@ -384,7 +383,7 @@ fn build_session_options(binary: str, match: getopts::match, binary_dir: str)
|
||||
none. { get_default_sysroot(binary) }
|
||||
some(s) { s }
|
||||
};
|
||||
let cfg = parse_cfgspecs(getopts::opt_strs_ivec(match, "cfg"));
|
||||
let cfg = parse_cfgspecs(getopts::opt_strs(match, "cfg"));
|
||||
let test = opt_present(match, "test");
|
||||
let dps = opt_present(match, "dps");
|
||||
let do_gc = opt_present(match, "gc");
|
||||
@ -447,7 +446,7 @@ fn main(args: vec[str]) {
|
||||
let binary = ivec::shift(args_ivec);
|
||||
let binary_dir = fs::dirname(binary);
|
||||
let match =
|
||||
alt getopts::getopts_ivec(args_ivec, opts()) {
|
||||
alt getopts::getopts(args_ivec, opts()) {
|
||||
getopts::success(m) { m }
|
||||
getopts::failure(f) {
|
||||
log_err #fmt("error: %s", getopts::fail_str(f));
|
||||
@ -464,7 +463,7 @@ fn main(args: vec[str]) {
|
||||
}
|
||||
let sopts = build_session_options(binary, match, binary_dir);
|
||||
let sess = build_session(sopts);
|
||||
let n_inputs = vec::len[str](match.free);
|
||||
let n_inputs = ivec::len[str](match.free);
|
||||
let output_file = getopts::opt_maybe_str(match, "o");
|
||||
let glue = opt_present(match, "glue");
|
||||
if glue {
|
||||
@ -652,7 +651,7 @@ mod test {
|
||||
#[test]
|
||||
fn test_switch_implies_cfg_test() {
|
||||
let match =
|
||||
alt getopts::getopts_ivec(~["--test"], opts()) {
|
||||
alt getopts::getopts(~["--test"], opts()) {
|
||||
getopts::success(m) { m }
|
||||
};
|
||||
let sessopts = build_session_options("whatever", match, "whatever");
|
||||
@ -666,7 +665,7 @@ mod test {
|
||||
#[test]
|
||||
fn test_switch_implies_cfg_test_unless_cfg_test() {
|
||||
let match =
|
||||
alt getopts::getopts_ivec(~["--test", "--cfg=test"], opts()) {
|
||||
alt getopts::getopts(~["--test", "--cfg=test"], opts()) {
|
||||
getopts::success(m) { m }
|
||||
};
|
||||
let sessopts = build_session_options("whatever", match, "whatever");
|
||||
|
@ -17,7 +17,6 @@ export optflag;
|
||||
export optflagopt;
|
||||
export optmulti;
|
||||
export getopts;
|
||||
export getopts_ivec;
|
||||
export result;
|
||||
export success;
|
||||
export failure;
|
||||
@ -27,7 +26,6 @@ export fail_str;
|
||||
export opt_present;
|
||||
export opt_str;
|
||||
export opt_strs;
|
||||
export opt_strs_ivec;
|
||||
export opt_maybe_str;
|
||||
export opt_default;
|
||||
|
||||
@ -67,7 +65,7 @@ fn optmulti(name: str) -> opt {
|
||||
|
||||
tag optval { val(str); given; }
|
||||
|
||||
type match = {opts: [opt], vals: [mutable [optval]], free: vec[str]};
|
||||
type match = {opts: [opt], vals: [mutable [optval]], free: [str]};
|
||||
|
||||
fn is_arg(arg: str) -> bool {
|
||||
ret str::byte_len(arg) > 1u && arg.(0) == '-' as u8;
|
||||
@ -108,30 +106,21 @@ fn fail_str(f: fail_) -> str {
|
||||
|
||||
tag result { success(match); failure(fail_); }
|
||||
|
||||
fn getopts(args: vec[str], opts: vec[opt]) -> result {
|
||||
// FIXME: Remove this vec->ivec conversion.
|
||||
let args_ivec = ~[];
|
||||
let opts_ivec = ~[];
|
||||
for arg: str in args { args_ivec += ~[arg]; }
|
||||
for o: opt in opts { opts_ivec += ~[o]; }
|
||||
ret getopts_ivec(args_ivec, opts_ivec);
|
||||
}
|
||||
|
||||
fn getopts_ivec(args: &[str], opts: &[opt]) -> result {
|
||||
fn getopts(args: &[str], opts: &[opt]) -> result {
|
||||
let n_opts = ivec::len[opt](opts);
|
||||
fn f(x: uint) -> [optval] { ret ~[]; }
|
||||
let vals = ivec::init_fn_mut[[optval]](f, n_opts);
|
||||
let free: vec[str] = [];
|
||||
let free: [str] = ~[];
|
||||
let l = ivec::len[str](args);
|
||||
let i = 0u;
|
||||
while i < l {
|
||||
let cur = args.(i);
|
||||
let curlen = str::byte_len(cur);
|
||||
if !is_arg(cur) {
|
||||
free += [cur];
|
||||
free += ~[cur];
|
||||
} else if (str::eq(cur, "--")) {
|
||||
let j = i + 1u;
|
||||
while j < l { free += [args.(j)]; j += 1u; }
|
||||
while j < l { free += ~[args.(j)]; j += 1u; }
|
||||
break;
|
||||
} else {
|
||||
let names;
|
||||
@ -227,15 +216,7 @@ fn opt_str(m: &match, nm: str) -> str {
|
||||
ret alt opt_val(m, nm) { val(s) { s } _ { fail } };
|
||||
}
|
||||
|
||||
fn opt_strs(m: &match, nm: str) -> vec[str] {
|
||||
let acc: vec[str] = [];
|
||||
for v: optval in opt_vals(m, nm) {
|
||||
alt v { val(s) { acc += [s]; } _ { } }
|
||||
}
|
||||
ret acc;
|
||||
}
|
||||
|
||||
fn opt_strs_ivec(m: &match, nm: str) -> [str] {
|
||||
fn opt_strs(m: &match, nm: str) -> [str] {
|
||||
let acc: [str] = ~[];
|
||||
for v: optval in opt_vals(m, nm) {
|
||||
alt v { val(s) { acc += ~[s]; } _ { } }
|
||||
|
@ -71,13 +71,13 @@ fn parse_opts(args: &[str]) : ivec::is_not_empty(args) -> opt_res {
|
||||
let args_ = ivec::tail(args);
|
||||
let opts = ~[getopts::optflag("ignored")];
|
||||
let match =
|
||||
alt getopts::getopts_ivec(args_, opts) {
|
||||
alt getopts::getopts(args_, opts) {
|
||||
getopts::success(m) { m }
|
||||
getopts::failure(f) { ret either::right(getopts::fail_str(f)) }
|
||||
};
|
||||
|
||||
let filter =
|
||||
if vec::len(match.free) > 0u {
|
||||
if ivec::len(match.free) > 0u {
|
||||
option::some(match.free.(0))
|
||||
} else { option::none };
|
||||
|
||||
|
@ -52,7 +52,7 @@ fn parse_opts(argv: [str]) -> config {
|
||||
let opt_args = ivec::slice(argv, 1u, ivec::len(argv));
|
||||
|
||||
|
||||
alt getopts::getopts_ivec(opt_args, opts) {
|
||||
alt getopts::getopts(opt_args, opts) {
|
||||
getopts::success(m) { ret {stress: getopts::opt_present(m, "stress")} }
|
||||
getopts::failure(_) { fail; }
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ fn parse_config(args: &[str]) -> config {
|
||||
check (ivec::is_not_empty(args));
|
||||
let args_ = ivec::tail(args);
|
||||
let match =
|
||||
alt getopts::getopts_ivec(args_, opts) {
|
||||
alt getopts::getopts(args_, opts) {
|
||||
getopts::success(m) { m }
|
||||
getopts::failure(f) { fail getopts::fail_str(f) }
|
||||
};
|
||||
@ -51,7 +51,7 @@ fn parse_config(args: &[str]) -> config {
|
||||
mode: str_mode(getopts::opt_str(match, "mode")),
|
||||
run_ignored: getopts::opt_present(match, "ignored"),
|
||||
filter:
|
||||
if vec::len(match.free) > 0u {
|
||||
if ivec::len(match.free) > 0u {
|
||||
option::some(match.free.(0))
|
||||
} else { option::none },
|
||||
runtool: getopts::opt_maybe_str(match, "runtool"),
|
||||
|
@ -1,6 +1,6 @@
|
||||
|
||||
use std;
|
||||
import std::vec;
|
||||
import std::ivec;
|
||||
import std::option;
|
||||
import opt = std::getopts;
|
||||
|
||||
@ -27,8 +27,8 @@ fn check_fail_type(f: opt::fail_, ft: fail_type) {
|
||||
// Tests for reqopt
|
||||
#[test]
|
||||
fn test_reqopt_long() {
|
||||
let args = ["--test=20"];
|
||||
let opts = [opt::reqopt("test")];
|
||||
let args = ~["--test=20"];
|
||||
let opts = ~[opt::reqopt("test")];
|
||||
let rs = opt::getopts(args, opts);
|
||||
alt rs {
|
||||
opt::success(m) {
|
||||
@ -41,8 +41,8 @@ fn test_reqopt_long() {
|
||||
|
||||
#[test]
|
||||
fn test_reqopt_long_missing() {
|
||||
let args = ["blah"];
|
||||
let opts = [opt::reqopt("test")];
|
||||
let args = ~["blah"];
|
||||
let opts = ~[opt::reqopt("test")];
|
||||
let rs = opt::getopts(args, opts);
|
||||
alt rs {
|
||||
opt::failure(f) { check_fail_type(f, option_missing); }
|
||||
@ -52,8 +52,8 @@ fn test_reqopt_long_missing() {
|
||||
|
||||
#[test]
|
||||
fn test_reqopt_long_no_arg() {
|
||||
let args = ["--test"];
|
||||
let opts = [opt::reqopt("test")];
|
||||
let args = ~["--test"];
|
||||
let opts = ~[opt::reqopt("test")];
|
||||
let rs = opt::getopts(args, opts);
|
||||
alt rs {
|
||||
opt::failure(f) { check_fail_type(f, argument_missing); }
|
||||
@ -63,8 +63,8 @@ fn test_reqopt_long_no_arg() {
|
||||
|
||||
#[test]
|
||||
fn test_reqopt_long_multi() {
|
||||
let args = ["--test=20", "--test=30"];
|
||||
let opts = [opt::reqopt("test")];
|
||||
let args = ~["--test=20", "--test=30"];
|
||||
let opts = ~[opt::reqopt("test")];
|
||||
let rs = opt::getopts(args, opts);
|
||||
alt rs {
|
||||
opt::failure(f) { check_fail_type(f, option_duplicated); }
|
||||
@ -74,8 +74,8 @@ fn test_reqopt_long_multi() {
|
||||
|
||||
#[test]
|
||||
fn test_reqopt_short() {
|
||||
let args = ["-t", "20"];
|
||||
let opts = [opt::reqopt("t")];
|
||||
let args = ~["-t", "20"];
|
||||
let opts = ~[opt::reqopt("t")];
|
||||
let rs = opt::getopts(args, opts);
|
||||
alt rs {
|
||||
opt::success(m) {
|
||||
@ -88,8 +88,8 @@ fn test_reqopt_short() {
|
||||
|
||||
#[test]
|
||||
fn test_reqopt_short_missing() {
|
||||
let args = ["blah"];
|
||||
let opts = [opt::reqopt("t")];
|
||||
let args = ~["blah"];
|
||||
let opts = ~[opt::reqopt("t")];
|
||||
let rs = opt::getopts(args, opts);
|
||||
alt rs {
|
||||
opt::failure(f) { check_fail_type(f, option_missing); }
|
||||
@ -99,8 +99,8 @@ fn test_reqopt_short_missing() {
|
||||
|
||||
#[test]
|
||||
fn test_reqopt_short_no_arg() {
|
||||
let args = ["-t"];
|
||||
let opts = [opt::reqopt("t")];
|
||||
let args = ~["-t"];
|
||||
let opts = ~[opt::reqopt("t")];
|
||||
let rs = opt::getopts(args, opts);
|
||||
alt rs {
|
||||
opt::failure(f) { check_fail_type(f, argument_missing); }
|
||||
@ -110,8 +110,8 @@ fn test_reqopt_short_no_arg() {
|
||||
|
||||
#[test]
|
||||
fn test_reqopt_short_multi() {
|
||||
let args = ["-t", "20", "-t", "30"];
|
||||
let opts = [opt::reqopt("t")];
|
||||
let args = ~["-t", "20", "-t", "30"];
|
||||
let opts = ~[opt::reqopt("t")];
|
||||
let rs = opt::getopts(args, opts);
|
||||
alt rs {
|
||||
opt::failure(f) { check_fail_type(f, option_duplicated); }
|
||||
@ -123,8 +123,8 @@ fn test_reqopt_short_multi() {
|
||||
// Tests for optopt
|
||||
#[test]
|
||||
fn test_optopt_long() {
|
||||
let args = ["--test=20"];
|
||||
let opts = [opt::optopt("test")];
|
||||
let args = ~["--test=20"];
|
||||
let opts = ~[opt::optopt("test")];
|
||||
let rs = opt::getopts(args, opts);
|
||||
alt rs {
|
||||
opt::success(m) {
|
||||
@ -137,8 +137,8 @@ fn test_optopt_long() {
|
||||
|
||||
#[test]
|
||||
fn test_optopt_long_missing() {
|
||||
let args = ["blah"];
|
||||
let opts = [opt::optopt("test")];
|
||||
let args = ~["blah"];
|
||||
let opts = ~[opt::optopt("test")];
|
||||
let rs = opt::getopts(args, opts);
|
||||
alt rs {
|
||||
opt::success(m) { assert (!opt::opt_present(m, "test")); }
|
||||
@ -148,8 +148,8 @@ fn test_optopt_long_missing() {
|
||||
|
||||
#[test]
|
||||
fn test_optopt_long_no_arg() {
|
||||
let args = ["--test"];
|
||||
let opts = [opt::optopt("test")];
|
||||
let args = ~["--test"];
|
||||
let opts = ~[opt::optopt("test")];
|
||||
let rs = opt::getopts(args, opts);
|
||||
alt rs {
|
||||
opt::failure(f) { check_fail_type(f, argument_missing); }
|
||||
@ -159,8 +159,8 @@ fn test_optopt_long_no_arg() {
|
||||
|
||||
#[test]
|
||||
fn test_optopt_long_multi() {
|
||||
let args = ["--test=20", "--test=30"];
|
||||
let opts = [opt::optopt("test")];
|
||||
let args = ~["--test=20", "--test=30"];
|
||||
let opts = ~[opt::optopt("test")];
|
||||
let rs = opt::getopts(args, opts);
|
||||
alt rs {
|
||||
opt::failure(f) { check_fail_type(f, option_duplicated); }
|
||||
@ -170,8 +170,8 @@ fn test_optopt_long_multi() {
|
||||
|
||||
#[test]
|
||||
fn test_optopt_short() {
|
||||
let args = ["-t", "20"];
|
||||
let opts = [opt::optopt("t")];
|
||||
let args = ~["-t", "20"];
|
||||
let opts = ~[opt::optopt("t")];
|
||||
let rs = opt::getopts(args, opts);
|
||||
alt rs {
|
||||
opt::success(m) {
|
||||
@ -184,8 +184,8 @@ fn test_optopt_short() {
|
||||
|
||||
#[test]
|
||||
fn test_optopt_short_missing() {
|
||||
let args = ["blah"];
|
||||
let opts = [opt::optopt("t")];
|
||||
let args = ~["blah"];
|
||||
let opts = ~[opt::optopt("t")];
|
||||
let rs = opt::getopts(args, opts);
|
||||
alt rs {
|
||||
opt::success(m) { assert (!opt::opt_present(m, "t")); }
|
||||
@ -195,8 +195,8 @@ fn test_optopt_short_missing() {
|
||||
|
||||
#[test]
|
||||
fn test_optopt_short_no_arg() {
|
||||
let args = ["-t"];
|
||||
let opts = [opt::optopt("t")];
|
||||
let args = ~["-t"];
|
||||
let opts = ~[opt::optopt("t")];
|
||||
let rs = opt::getopts(args, opts);
|
||||
alt rs {
|
||||
opt::failure(f) { check_fail_type(f, argument_missing); }
|
||||
@ -206,8 +206,8 @@ fn test_optopt_short_no_arg() {
|
||||
|
||||
#[test]
|
||||
fn test_optopt_short_multi() {
|
||||
let args = ["-t", "20", "-t", "30"];
|
||||
let opts = [opt::optopt("t")];
|
||||
let args = ~["-t", "20", "-t", "30"];
|
||||
let opts = ~[opt::optopt("t")];
|
||||
let rs = opt::getopts(args, opts);
|
||||
alt rs {
|
||||
opt::failure(f) { check_fail_type(f, option_duplicated); }
|
||||
@ -219,8 +219,8 @@ fn test_optopt_short_multi() {
|
||||
// Tests for optflag
|
||||
#[test]
|
||||
fn test_optflag_long() {
|
||||
let args = ["--test"];
|
||||
let opts = [opt::optflag("test")];
|
||||
let args = ~["--test"];
|
||||
let opts = ~[opt::optflag("test")];
|
||||
let rs = opt::getopts(args, opts);
|
||||
alt rs {
|
||||
opt::success(m) { assert (opt::opt_present(m, "test")); }
|
||||
@ -230,8 +230,8 @@ fn test_optflag_long() {
|
||||
|
||||
#[test]
|
||||
fn test_optflag_long_missing() {
|
||||
let args = ["blah"];
|
||||
let opts = [opt::optflag("test")];
|
||||
let args = ~["blah"];
|
||||
let opts = ~[opt::optflag("test")];
|
||||
let rs = opt::getopts(args, opts);
|
||||
alt rs {
|
||||
opt::success(m) { assert (!opt::opt_present(m, "test")); }
|
||||
@ -241,8 +241,8 @@ fn test_optflag_long_missing() {
|
||||
|
||||
#[test]
|
||||
fn test_optflag_long_arg() {
|
||||
let args = ["--test=20"];
|
||||
let opts = [opt::optflag("test")];
|
||||
let args = ~["--test=20"];
|
||||
let opts = ~[opt::optflag("test")];
|
||||
let rs = opt::getopts(args, opts);
|
||||
alt rs {
|
||||
opt::failure(f) {
|
||||
@ -255,8 +255,8 @@ fn test_optflag_long_arg() {
|
||||
|
||||
#[test]
|
||||
fn test_optflag_long_multi() {
|
||||
let args = ["--test", "--test"];
|
||||
let opts = [opt::optflag("test")];
|
||||
let args = ~["--test", "--test"];
|
||||
let opts = ~[opt::optflag("test")];
|
||||
let rs = opt::getopts(args, opts);
|
||||
alt rs {
|
||||
opt::failure(f) { check_fail_type(f, option_duplicated); }
|
||||
@ -266,8 +266,8 @@ fn test_optflag_long_multi() {
|
||||
|
||||
#[test]
|
||||
fn test_optflag_short() {
|
||||
let args = ["-t"];
|
||||
let opts = [opt::optflag("t")];
|
||||
let args = ~["-t"];
|
||||
let opts = ~[opt::optflag("t")];
|
||||
let rs = opt::getopts(args, opts);
|
||||
alt rs {
|
||||
opt::success(m) { assert (opt::opt_present(m, "t")); }
|
||||
@ -277,8 +277,8 @@ fn test_optflag_short() {
|
||||
|
||||
#[test]
|
||||
fn test_optflag_short_missing() {
|
||||
let args = ["blah"];
|
||||
let opts = [opt::optflag("t")];
|
||||
let args = ~["blah"];
|
||||
let opts = ~[opt::optflag("t")];
|
||||
let rs = opt::getopts(args, opts);
|
||||
alt rs {
|
||||
opt::success(m) { assert (!opt::opt_present(m, "t")); }
|
||||
@ -288,8 +288,8 @@ fn test_optflag_short_missing() {
|
||||
|
||||
#[test]
|
||||
fn test_optflag_short_arg() {
|
||||
let args = ["-t", "20"];
|
||||
let opts = [opt::optflag("t")];
|
||||
let args = ~["-t", "20"];
|
||||
let opts = ~[opt::optflag("t")];
|
||||
let rs = opt::getopts(args, opts);
|
||||
alt rs {
|
||||
opt::success(m) {
|
||||
@ -303,8 +303,8 @@ fn test_optflag_short_arg() {
|
||||
|
||||
#[test]
|
||||
fn test_optflag_short_multi() {
|
||||
let args = ["-t", "-t"];
|
||||
let opts = [opt::optflag("t")];
|
||||
let args = ~["-t", "-t"];
|
||||
let opts = ~[opt::optflag("t")];
|
||||
let rs = opt::getopts(args, opts);
|
||||
alt rs {
|
||||
opt::failure(f) { check_fail_type(f, option_duplicated); }
|
||||
@ -316,8 +316,8 @@ fn test_optflag_short_multi() {
|
||||
// Tests for optmulti
|
||||
#[test]
|
||||
fn test_optmulti_long() {
|
||||
let args = ["--test=20"];
|
||||
let opts = [opt::optmulti("test")];
|
||||
let args = ~["--test=20"];
|
||||
let opts = ~[opt::optmulti("test")];
|
||||
let rs = opt::getopts(args, opts);
|
||||
alt rs {
|
||||
opt::success(m) {
|
||||
@ -330,8 +330,8 @@ fn test_optmulti_long() {
|
||||
|
||||
#[test]
|
||||
fn test_optmulti_long_missing() {
|
||||
let args = ["blah"];
|
||||
let opts = [opt::optmulti("test")];
|
||||
let args = ~["blah"];
|
||||
let opts = ~[opt::optmulti("test")];
|
||||
let rs = opt::getopts(args, opts);
|
||||
alt rs {
|
||||
opt::success(m) { assert (!opt::opt_present(m, "test")); }
|
||||
@ -341,8 +341,8 @@ fn test_optmulti_long_missing() {
|
||||
|
||||
#[test]
|
||||
fn test_optmulti_long_no_arg() {
|
||||
let args = ["--test"];
|
||||
let opts = [opt::optmulti("test")];
|
||||
let args = ~["--test"];
|
||||
let opts = ~[opt::optmulti("test")];
|
||||
let rs = opt::getopts(args, opts);
|
||||
alt rs {
|
||||
opt::failure(f) { check_fail_type(f, argument_missing); }
|
||||
@ -352,8 +352,8 @@ fn test_optmulti_long_no_arg() {
|
||||
|
||||
#[test]
|
||||
fn test_optmulti_long_multi() {
|
||||
let args = ["--test=20", "--test=30"];
|
||||
let opts = [opt::optmulti("test")];
|
||||
let args = ~["--test=20", "--test=30"];
|
||||
let opts = ~[opt::optmulti("test")];
|
||||
let rs = opt::getopts(args, opts);
|
||||
alt rs {
|
||||
opt::success(m) {
|
||||
@ -368,8 +368,8 @@ fn test_optmulti_long_multi() {
|
||||
|
||||
#[test]
|
||||
fn test_optmulti_short() {
|
||||
let args = ["-t", "20"];
|
||||
let opts = [opt::optmulti("t")];
|
||||
let args = ~["-t", "20"];
|
||||
let opts = ~[opt::optmulti("t")];
|
||||
let rs = opt::getopts(args, opts);
|
||||
alt rs {
|
||||
opt::success(m) {
|
||||
@ -382,8 +382,8 @@ fn test_optmulti_short() {
|
||||
|
||||
#[test]
|
||||
fn test_optmulti_short_missing() {
|
||||
let args = ["blah"];
|
||||
let opts = [opt::optmulti("t")];
|
||||
let args = ~["blah"];
|
||||
let opts = ~[opt::optmulti("t")];
|
||||
let rs = opt::getopts(args, opts);
|
||||
alt rs {
|
||||
opt::success(m) { assert (!opt::opt_present(m, "t")); }
|
||||
@ -393,8 +393,8 @@ fn test_optmulti_short_missing() {
|
||||
|
||||
#[test]
|
||||
fn test_optmulti_short_no_arg() {
|
||||
let args = ["-t"];
|
||||
let opts = [opt::optmulti("t")];
|
||||
let args = ~["-t"];
|
||||
let opts = ~[opt::optmulti("t")];
|
||||
let rs = opt::getopts(args, opts);
|
||||
alt rs {
|
||||
opt::failure(f) { check_fail_type(f, argument_missing); }
|
||||
@ -404,8 +404,8 @@ fn test_optmulti_short_no_arg() {
|
||||
|
||||
#[test]
|
||||
fn test_optmulti_short_multi() {
|
||||
let args = ["-t", "20", "-t", "30"];
|
||||
let opts = [opt::optmulti("t")];
|
||||
let args = ~["-t", "20", "-t", "30"];
|
||||
let opts = ~[opt::optmulti("t")];
|
||||
let rs = opt::getopts(args, opts);
|
||||
alt rs {
|
||||
opt::success(m) {
|
||||
@ -420,8 +420,8 @@ fn test_optmulti_short_multi() {
|
||||
|
||||
#[test]
|
||||
fn test_unrecognized_option_long() {
|
||||
let args = ["--untest"];
|
||||
let opts = [opt::optmulti("t")];
|
||||
let args = ~["--untest"];
|
||||
let opts = ~[opt::optmulti("t")];
|
||||
let rs = opt::getopts(args, opts);
|
||||
alt rs {
|
||||
opt::failure(f) { check_fail_type(f, unrecognized_option); }
|
||||
@ -431,8 +431,8 @@ fn test_unrecognized_option_long() {
|
||||
|
||||
#[test]
|
||||
fn test_unrecognized_option_short() {
|
||||
let args = ["-t"];
|
||||
let opts = [opt::optmulti("test")];
|
||||
let args = ~["-t"];
|
||||
let opts = ~[opt::optmulti("test")];
|
||||
let rs = opt::getopts(args, opts);
|
||||
alt rs {
|
||||
opt::failure(f) { check_fail_type(f, unrecognized_option); }
|
||||
@ -443,10 +443,10 @@ fn test_unrecognized_option_short() {
|
||||
#[test]
|
||||
fn test_combined() {
|
||||
let args =
|
||||
["prog", "free1", "-s", "20", "free2", "--flag", "--long=30", "-f",
|
||||
~["prog", "free1", "-s", "20", "free2", "--flag", "--long=30", "-f",
|
||||
"-m", "40", "-m", "50"];
|
||||
let opts =
|
||||
[opt::optopt("s"), opt::optflag("flag"), opt::reqopt("long"),
|
||||
~[opt::optopt("s"), opt::optflag("flag"), opt::reqopt("long"),
|
||||
opt::optflag("f"), opt::optmulti("m"), opt::optopt("notpresent")];
|
||||
let rs = opt::getopts(args, opts);
|
||||
alt rs {
|
||||
|
Loading…
Reference in New Issue
Block a user