Turned extra::getopts functions into methods
Some minor api and doc adjustments
This commit is contained in:
parent
3c0013134c
commit
06d1dccf95
10 changed files with 668 additions and 647 deletions
|
@ -91,10 +91,10 @@ pub fn parse_config(args: ~[~str]) -> config {
|
|||
let matches =
|
||||
&match getopts::groups::getopts(args_, groups) {
|
||||
Ok(m) => m,
|
||||
Err(f) => fail!(getopts::fail_str(f))
|
||||
Err(f) => fail!(f.to_err_msg())
|
||||
};
|
||||
|
||||
if getopts::opt_present(matches, "h") || getopts::opt_present(matches, "help") {
|
||||
if matches.opt_present("h") || matches.opt_present("help") {
|
||||
let message = fmt!("Usage: %s [OPTIONS] [TESTNAME...]", argv0);
|
||||
println(getopts::groups::usage(message, groups));
|
||||
println("");
|
||||
|
@ -102,53 +102,51 @@ pub fn parse_config(args: ~[~str]) -> config {
|
|||
}
|
||||
|
||||
fn opt_path(m: &getopts::Matches, nm: &str) -> Path {
|
||||
Path(getopts::opt_str(m, nm))
|
||||
Path(m.opt_str(nm).unwrap())
|
||||
}
|
||||
|
||||
config {
|
||||
compile_lib_path: getopts::opt_str(matches, "compile-lib-path"),
|
||||
run_lib_path: getopts::opt_str(matches, "run-lib-path"),
|
||||
compile_lib_path: matches.opt_str("compile-lib-path").unwrap(),
|
||||
run_lib_path: matches.opt_str("run-lib-path").unwrap(),
|
||||
rustc_path: opt_path(matches, "rustc-path"),
|
||||
clang_path: getopts::opt_maybe_str(matches, "clang-path").map_move(|s| Path(s)),
|
||||
llvm_bin_path: getopts::opt_maybe_str(matches, "llvm-bin-path").map_move(|s| Path(s)),
|
||||
clang_path: matches.opt_str("clang-path").map_move(|s| Path(s)),
|
||||
llvm_bin_path: matches.opt_str("llvm-bin-path").map_move(|s| Path(s)),
|
||||
src_base: opt_path(matches, "src-base"),
|
||||
build_base: opt_path(matches, "build-base"),
|
||||
aux_base: opt_path(matches, "aux-base"),
|
||||
stage_id: getopts::opt_str(matches, "stage-id"),
|
||||
mode: str_mode(getopts::opt_str(matches, "mode")),
|
||||
run_ignored: getopts::opt_present(matches, "ignored"),
|
||||
stage_id: matches.opt_str("stage-id").unwrap(),
|
||||
mode: str_mode(matches.opt_str("mode").unwrap()),
|
||||
run_ignored: matches.opt_present("ignored"),
|
||||
filter:
|
||||
if !matches.free.is_empty() {
|
||||
Some(matches.free[0].clone())
|
||||
} else {
|
||||
None
|
||||
},
|
||||
logfile: getopts::opt_maybe_str(matches, "logfile").map_move(|s| Path(s)),
|
||||
save_metrics: getopts::opt_maybe_str(matches, "save-metrics").map_move(|s| Path(s)),
|
||||
logfile: matches.opt_str("logfile").map_move(|s| Path(s)),
|
||||
save_metrics: matches.opt_str("save-metrics").map_move(|s| Path(s)),
|
||||
ratchet_metrics:
|
||||
getopts::opt_maybe_str(matches, "ratchet-metrics").map_move(|s| Path(s)),
|
||||
matches.opt_str("ratchet-metrics").map_move(|s| Path(s)),
|
||||
ratchet_noise_percent:
|
||||
getopts::opt_maybe_str(matches,
|
||||
"ratchet-noise-percent").map_move(|s|
|
||||
from_str::<f64>(s).unwrap()),
|
||||
runtool: getopts::opt_maybe_str(matches, "runtool"),
|
||||
rustcflags: getopts::opt_maybe_str(matches, "rustcflags"),
|
||||
jit: getopts::opt_present(matches, "jit"),
|
||||
target: opt_str2(getopts::opt_maybe_str(matches, "target")).to_str(),
|
||||
adb_path: opt_str2(getopts::opt_maybe_str(matches, "adb-path")).to_str(),
|
||||
matches.opt_str("ratchet-noise-percent").and_then(|s| from_str::<f64>(s)),
|
||||
runtool: matches.opt_str("runtool"),
|
||||
rustcflags: matches.opt_str("rustcflags"),
|
||||
jit: matches.opt_present("jit"),
|
||||
target: opt_str2(matches.opt_str("target")).to_str(),
|
||||
adb_path: opt_str2(matches.opt_str("adb-path")).to_str(),
|
||||
adb_test_dir:
|
||||
opt_str2(getopts::opt_maybe_str(matches, "adb-test-dir")).to_str(),
|
||||
opt_str2(matches.opt_str("adb-test-dir")).to_str(),
|
||||
adb_device_status:
|
||||
if (opt_str2(getopts::opt_maybe_str(matches, "target")) ==
|
||||
if (opt_str2(matches.opt_str("target")) ==
|
||||
~"arm-linux-androideabi") {
|
||||
if (opt_str2(getopts::opt_maybe_str(matches, "adb-test-dir")) !=
|
||||
if (opt_str2(matches.opt_str("adb-test-dir")) !=
|
||||
~"(none)" &&
|
||||
opt_str2(getopts::opt_maybe_str(matches, "adb-test-dir")) !=
|
||||
opt_str2(matches.opt_str("adb-test-dir")) !=
|
||||
~"") { true }
|
||||
else { false }
|
||||
} else { false },
|
||||
test_shard: test::opt_shard(getopts::opt_maybe_str(matches, "test-shard")),
|
||||
verbose: getopts::opt_present(matches, "verbose")
|
||||
test_shard: test::opt_shard(matches.opt_str("test-shard")),
|
||||
verbose: matches.opt_present("verbose")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -226,11 +226,11 @@ pub fn parse_opts(args: &[~str]) -> OptRes {
|
|||
let matches =
|
||||
match groups::getopts(args_, optgroups()) {
|
||||
Ok(m) => m,
|
||||
Err(f) => return Err(getopts::fail_str(f))
|
||||
Err(f) => return Err(f.to_err_msg())
|
||||
};
|
||||
|
||||
if getopts::opt_present(&matches, "h") { usage(args[0], "h"); }
|
||||
if getopts::opt_present(&matches, "help") { usage(args[0], "help"); }
|
||||
if matches.opt_present("h") { usage(args[0], "h"); }
|
||||
if matches.opt_present("help") { usage(args[0], "help"); }
|
||||
|
||||
let filter =
|
||||
if matches.free.len() > 0 {
|
||||
|
@ -239,25 +239,25 @@ pub fn parse_opts(args: &[~str]) -> OptRes {
|
|||
None
|
||||
};
|
||||
|
||||
let run_ignored = getopts::opt_present(&matches, "ignored");
|
||||
let run_ignored = matches.opt_present("ignored");
|
||||
|
||||
let logfile = getopts::opt_maybe_str(&matches, "logfile");
|
||||
let logfile = matches.opt_str("logfile");
|
||||
let logfile = logfile.map_move(|s| Path(s));
|
||||
|
||||
let run_benchmarks = getopts::opt_present(&matches, "bench");
|
||||
let run_benchmarks = matches.opt_present("bench");
|
||||
let run_tests = ! run_benchmarks ||
|
||||
getopts::opt_present(&matches, "test");
|
||||
matches.opt_present("test");
|
||||
|
||||
let ratchet_metrics = getopts::opt_maybe_str(&matches, "ratchet-metrics");
|
||||
let ratchet_metrics = matches.opt_str("ratchet-metrics");
|
||||
let ratchet_metrics = ratchet_metrics.map_move(|s| Path(s));
|
||||
|
||||
let ratchet_noise_percent = getopts::opt_maybe_str(&matches, "ratchet-noise-percent");
|
||||
let ratchet_noise_percent = matches.opt_str("ratchet-noise-percent");
|
||||
let ratchet_noise_percent = ratchet_noise_percent.map_move(|s| from_str::<f64>(s).unwrap());
|
||||
|
||||
let save_metrics = getopts::opt_maybe_str(&matches, "save-metrics");
|
||||
let save_metrics = matches.opt_str("save-metrics");
|
||||
let save_metrics = save_metrics.map_move(|s| Path(s));
|
||||
|
||||
let test_shard = getopts::opt_maybe_str(&matches, "test-shard");
|
||||
let test_shard = matches.opt_str("test-shard");
|
||||
let test_shard = opt_shard(test_shard);
|
||||
|
||||
let test_opts = TestOpts {
|
||||
|
|
|
@ -30,7 +30,6 @@ use std::io;
|
|||
use std::os;
|
||||
use std::vec;
|
||||
use extra::getopts::groups::{optopt, optmulti, optflag, optflagopt};
|
||||
use extra::getopts::{opt_present};
|
||||
use extra::getopts;
|
||||
use syntax::ast;
|
||||
use syntax::abi;
|
||||
|
@ -606,15 +605,15 @@ pub fn build_session_options(binary: @str,
|
|||
matches: &getopts::Matches,
|
||||
demitter: diagnostic::Emitter)
|
||||
-> @session::options {
|
||||
let crate_type = if opt_present(matches, "lib") {
|
||||
let crate_type = if matches.opt_present("lib") {
|
||||
session::lib_crate
|
||||
} else if opt_present(matches, "bin") {
|
||||
} else if matches.opt_present("bin") {
|
||||
session::bin_crate
|
||||
} else {
|
||||
session::unknown_crate
|
||||
};
|
||||
let parse_only = opt_present(matches, "parse-only");
|
||||
let no_trans = opt_present(matches, "no-trans");
|
||||
let parse_only = matches.opt_present("parse-only");
|
||||
let no_trans = matches.opt_present("no-trans");
|
||||
|
||||
let lint_levels = [lint::allow, lint::warn,
|
||||
lint::deny, lint::forbid];
|
||||
|
@ -627,8 +626,8 @@ pub fn build_session_options(binary: @str,
|
|||
// to_ascii_move and to_str_move to not do a unnecessary copy.
|
||||
let level_short = level_name.slice_chars(0, 1);
|
||||
let level_short = level_short.to_ascii().to_upper().to_str_ascii();
|
||||
let flags = vec::append(getopts::opt_strs(matches, level_short),
|
||||
getopts::opt_strs(matches, level_name));
|
||||
let flags = vec::append(matches.opt_strs(level_short),
|
||||
matches.opt_strs(level_name));
|
||||
for lint_name in flags.iter() {
|
||||
let lint_name = lint_name.replace("-", "_");
|
||||
match lint_dict.find_equiv(&lint_name) {
|
||||
|
@ -644,7 +643,7 @@ pub fn build_session_options(binary: @str,
|
|||
}
|
||||
|
||||
let mut debugging_opts = 0u;
|
||||
let debug_flags = getopts::opt_strs(matches, "Z");
|
||||
let debug_flags = matches.opt_strs("Z");
|
||||
let debug_map = session::debugging_opts_map();
|
||||
for debug_flag in debug_flags.iter() {
|
||||
let mut this_bit = 0u;
|
||||
|
@ -670,31 +669,31 @@ pub fn build_session_options(binary: @str,
|
|||
let output_type =
|
||||
if parse_only || no_trans {
|
||||
link::output_type_none
|
||||
} else if opt_present(matches, "S") &&
|
||||
opt_present(matches, "emit-llvm") {
|
||||
} else if matches.opt_present("S") &&
|
||||
matches.opt_present("emit-llvm") {
|
||||
link::output_type_llvm_assembly
|
||||
} else if opt_present(matches, "S") {
|
||||
} else if matches.opt_present("S") {
|
||||
link::output_type_assembly
|
||||
} else if opt_present(matches, "c") {
|
||||
} else if matches.opt_present("c") {
|
||||
link::output_type_object
|
||||
} else if opt_present(matches, "emit-llvm") {
|
||||
} else if matches.opt_present("emit-llvm") {
|
||||
link::output_type_bitcode
|
||||
} else { link::output_type_exe };
|
||||
let sysroot_opt = getopts::opt_maybe_str(matches, "sysroot").map_move(|m| @Path(m));
|
||||
let target = getopts::opt_maybe_str(matches, "target").unwrap_or(host_triple());
|
||||
let target_cpu = getopts::opt_maybe_str(matches, "target-cpu").unwrap_or(~"generic");
|
||||
let target_feature = getopts::opt_maybe_str(matches, "target-feature").unwrap_or(~"");
|
||||
let save_temps = getopts::opt_present(matches, "save-temps");
|
||||
let sysroot_opt = matches.opt_str("sysroot").map_move(|m| @Path(m));
|
||||
let target = matches.opt_str("target").unwrap_or(host_triple());
|
||||
let target_cpu = matches.opt_str("target-cpu").unwrap_or(~"generic");
|
||||
let target_feature = matches.opt_str("target-feature").unwrap_or(~"");
|
||||
let save_temps = matches.opt_present("save-temps");
|
||||
let opt_level = {
|
||||
if (debugging_opts & session::no_opt) != 0 {
|
||||
No
|
||||
} else if opt_present(matches, "O") {
|
||||
if opt_present(matches, "opt-level") {
|
||||
} else if matches.opt_present("O") {
|
||||
if matches.opt_present("opt-level") {
|
||||
early_error(demitter, ~"-O and --opt-level both provided");
|
||||
}
|
||||
Default
|
||||
} else if opt_present(matches, "opt-level") {
|
||||
match getopts::opt_str(matches, "opt-level") {
|
||||
} else if matches.opt_present("opt-level") {
|
||||
match matches.opt_str("opt-level").unwrap() {
|
||||
~"0" => No,
|
||||
~"1" => Less,
|
||||
~"2" => Default,
|
||||
|
@ -720,18 +719,17 @@ pub fn build_session_options(binary: @str,
|
|||
|
||||
let statik = debugging_opts & session::statik != 0;
|
||||
|
||||
let addl_lib_search_paths = getopts::opt_strs(matches, "L").map(|s| Path(*s));
|
||||
let linker = getopts::opt_maybe_str(matches, "linker");
|
||||
let linker_args = getopts::opt_strs(matches, "link-args").flat_map( |a| {
|
||||
let addl_lib_search_paths = matches.opt_strs("L").map(|s| Path(*s));
|
||||
let linker = matches.opt_str("linker");
|
||||
let linker_args = matches.opt_strs("link-args").flat_map( |a| {
|
||||
a.split_iter(' ').map(|arg| arg.to_owned()).collect()
|
||||
});
|
||||
|
||||
let cfg = parse_cfgspecs(getopts::opt_strs(matches, "cfg"), demitter);
|
||||
let test = opt_present(matches, "test");
|
||||
let android_cross_path = getopts::opt_maybe_str(
|
||||
matches, "android-cross-path");
|
||||
let cfg = parse_cfgspecs(matches.opt_strs("cfg"), demitter);
|
||||
let test = matches.opt_present("test");
|
||||
let android_cross_path = matches.opt_str("android-cross-path");
|
||||
|
||||
let custom_passes = match getopts::opt_maybe_str(matches, "passes") {
|
||||
let custom_passes = match matches.opt_str("passes") {
|
||||
None => ~[],
|
||||
Some(s) => {
|
||||
s.split_iter(|c: char| c == ' ' || c == ',').map(|s| {
|
||||
|
@ -739,7 +737,7 @@ pub fn build_session_options(binary: @str,
|
|||
}).collect()
|
||||
}
|
||||
};
|
||||
let llvm_args = match getopts::opt_maybe_str(matches, "llvm-args") {
|
||||
let llvm_args = match matches.opt_str("llvm-args") {
|
||||
None => ~[],
|
||||
Some(s) => {
|
||||
s.split_iter(|c: char| c == ' ' || c == ',').map(|s| {
|
||||
|
@ -1020,7 +1018,6 @@ mod test {
|
|||
use driver::driver::{build_session_options, optgroups};
|
||||
|
||||
use extra::getopts::groups::getopts;
|
||||
use extra::getopts;
|
||||
use syntax::attr;
|
||||
use syntax::diagnostic;
|
||||
|
||||
|
@ -1030,7 +1027,7 @@ mod test {
|
|||
let matches =
|
||||
&match getopts([~"--test"], optgroups()) {
|
||||
Ok(m) => m,
|
||||
Err(f) => fail!("test_switch_implies_cfg_test: %s", getopts::fail_str(f))
|
||||
Err(f) => fail!("test_switch_implies_cfg_test: %s", f.to_err_msg())
|
||||
};
|
||||
let sessopts = build_session_options(
|
||||
@"rustc", matches, diagnostic::emit);
|
||||
|
@ -1047,7 +1044,7 @@ mod test {
|
|||
&match getopts([~"--test", ~"--cfg=test"], optgroups()) {
|
||||
Ok(m) => m,
|
||||
Err(f) => {
|
||||
fail!("test_switch_implies_cfg_test_unless_cfg_test: %s", getopts::fail_str(f));
|
||||
fail!("test_switch_implies_cfg_test_unless_cfg_test: %s", f.to_err_msg());
|
||||
}
|
||||
};
|
||||
let sessopts = build_session_options(
|
||||
|
|
|
@ -40,7 +40,7 @@ use std::result;
|
|||
use std::str;
|
||||
use std::task;
|
||||
use std::vec;
|
||||
use extra::getopts::{groups, opt_present};
|
||||
use extra::getopts::groups;
|
||||
use extra::getopts;
|
||||
use syntax::codemap;
|
||||
use syntax::diagnostic;
|
||||
|
@ -204,39 +204,39 @@ pub fn run_compiler(args: &[~str], demitter: diagnostic::Emitter) {
|
|||
&match getopts::groups::getopts(args, optgroups()) {
|
||||
Ok(m) => m,
|
||||
Err(f) => {
|
||||
early_error(demitter, getopts::fail_str(f));
|
||||
early_error(demitter, f.to_err_msg());
|
||||
}
|
||||
};
|
||||
|
||||
if opt_present(matches, "h") || opt_present(matches, "help") {
|
||||
if matches.opt_present("h") || matches.opt_present("help") {
|
||||
usage(binary);
|
||||
return;
|
||||
}
|
||||
|
||||
// Display the available lint options if "-W help" or only "-W" is given.
|
||||
let lint_flags = vec::append(getopts::opt_strs(matches, "W"),
|
||||
getopts::opt_strs(matches, "warn"));
|
||||
let lint_flags = vec::append(matches.opt_strs("W"),
|
||||
matches.opt_strs("warn"));
|
||||
|
||||
let show_lint_options = lint_flags.iter().any(|x| x == &~"help") ||
|
||||
(opt_present(matches, "W") && lint_flags.is_empty());
|
||||
(matches.opt_present("W") && lint_flags.is_empty());
|
||||
|
||||
if show_lint_options {
|
||||
describe_warnings();
|
||||
return;
|
||||
}
|
||||
|
||||
let r = getopts::opt_strs(matches, "Z");
|
||||
let r = matches.opt_strs("Z");
|
||||
if r.iter().any(|x| x == &~"help") {
|
||||
describe_debug_flags();
|
||||
return;
|
||||
}
|
||||
|
||||
if getopts::opt_maybe_str(matches, "passes") == Some(~"list") {
|
||||
if matches.opt_str("passes") == Some(~"list") {
|
||||
unsafe { lib::llvm::llvm::LLVMRustPrintPasses(); }
|
||||
return;
|
||||
}
|
||||
|
||||
if opt_present(matches, "v") || opt_present(matches, "version") {
|
||||
if matches.opt_present("v") || matches.opt_present("version") {
|
||||
version(binary);
|
||||
return;
|
||||
}
|
||||
|
@ -256,10 +256,10 @@ pub fn run_compiler(args: &[~str], demitter: diagnostic::Emitter) {
|
|||
|
||||
let sopts = build_session_options(binary, matches, demitter);
|
||||
let sess = build_session(sopts, demitter);
|
||||
let odir = getopts::opt_maybe_str(matches, "out-dir").map_move(|o| Path(o));
|
||||
let ofile = getopts::opt_maybe_str(matches, "o").map_move(|o| Path(o));
|
||||
let odir = matches.opt_str("out-dir").map_move(|o| Path(o));
|
||||
let ofile = matches.opt_str("o").map_move(|o| Path(o));
|
||||
let cfg = build_configuration(sess);
|
||||
let pretty = do getopts::opt_default(matches, "pretty", "normal").map_move |a| {
|
||||
let pretty = do matches.opt_default("pretty", "normal").map_move |a| {
|
||||
parse_pretty(sess, a)
|
||||
};
|
||||
match pretty {
|
||||
|
@ -269,7 +269,7 @@ pub fn run_compiler(args: &[~str], demitter: diagnostic::Emitter) {
|
|||
}
|
||||
None::<PpMode> => {/* continue */ }
|
||||
}
|
||||
let ls = opt_present(matches, "ls");
|
||||
let ls = matches.opt_present("ls");
|
||||
if ls {
|
||||
match input {
|
||||
file_input(ref ifile) => {
|
||||
|
|
|
@ -125,7 +125,7 @@ pub fn parse_config_(
|
|||
}
|
||||
}
|
||||
Err(f) => {
|
||||
Err(getopts::fail_str(f))
|
||||
Err(f.to_err_msg())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ fn config_from_opts(
|
|||
let config = default_config(input_crate);
|
||||
let result = result::Ok(config);
|
||||
let result = do result.and_then |config| {
|
||||
let output_dir = getopts::opt_maybe_str(matches, opt_output_dir());
|
||||
let output_dir = matches.opt_str(opt_output_dir());
|
||||
let output_dir = output_dir.map_move(|s| Path(s));
|
||||
result::Ok(Config {
|
||||
output_dir: output_dir.unwrap_or(config.output_dir.clone()),
|
||||
|
@ -147,7 +147,7 @@ fn config_from_opts(
|
|||
})
|
||||
};
|
||||
let result = do result.and_then |config| {
|
||||
let output_format = getopts::opt_maybe_str(matches, opt_output_format());
|
||||
let output_format = matches.opt_str(opt_output_format());
|
||||
do output_format.map_move_default(result::Ok(config.clone())) |output_format| {
|
||||
do parse_output_format(output_format).and_then |output_format| {
|
||||
result::Ok(Config {
|
||||
|
@ -159,7 +159,7 @@ fn config_from_opts(
|
|||
};
|
||||
let result = do result.and_then |config| {
|
||||
let output_style =
|
||||
getopts::opt_maybe_str(matches, opt_output_style());
|
||||
matches.opt_str(opt_output_style());
|
||||
do output_style.map_move_default(result::Ok(config.clone())) |output_style| {
|
||||
do parse_output_style(output_style).and_then |output_style| {
|
||||
result::Ok(Config {
|
||||
|
@ -171,7 +171,7 @@ fn config_from_opts(
|
|||
};
|
||||
let process_output = Cell::new(process_output);
|
||||
let result = do result.and_then |config| {
|
||||
let pandoc_cmd = getopts::opt_maybe_str(matches, opt_pandoc_cmd());
|
||||
let pandoc_cmd = matches.opt_str(opt_pandoc_cmd());
|
||||
let pandoc_cmd = maybe_find_pandoc(
|
||||
&config, pandoc_cmd, process_output.take());
|
||||
do pandoc_cmd.and_then |pandoc_cmd| {
|
||||
|
|
|
@ -641,53 +641,53 @@ pub fn main_args(args: &[~str]) {
|
|||
let matches = &match getopts::getopts(args, opts) {
|
||||
result::Ok(m) => m,
|
||||
result::Err(f) => {
|
||||
error(fmt!("%s", getopts::fail_str(f)));
|
||||
error(fmt!("%s", f.to_err_msg()));
|
||||
|
||||
return;
|
||||
}
|
||||
};
|
||||
let mut help = getopts::opt_present(matches, "h") ||
|
||||
getopts::opt_present(matches, "help");
|
||||
let no_link = getopts::opt_present(matches, "no-link");
|
||||
let no_trans = getopts::opt_present(matches, "no-trans");
|
||||
let supplied_sysroot = getopts::opt_val(matches, "sysroot");
|
||||
let generate_asm = getopts::opt_present(matches, "S") ||
|
||||
getopts::opt_present(matches, "assembly");
|
||||
let parse_only = getopts::opt_present(matches, "parse-only");
|
||||
let pretty = getopts::opt_present(matches, "pretty");
|
||||
let emit_llvm = getopts::opt_present(matches, "emit-llvm");
|
||||
let mut help = matches.opt_present("h") ||
|
||||
matches.opt_present("help");
|
||||
let no_link = matches.opt_present("no-link");
|
||||
let no_trans = matches.opt_present("no-trans");
|
||||
let supplied_sysroot = matches.opt_val("sysroot");
|
||||
let generate_asm = matches.opt_present("S") ||
|
||||
matches.opt_present("assembly");
|
||||
let parse_only = matches.opt_present("parse-only");
|
||||
let pretty = matches.opt_present("pretty");
|
||||
let emit_llvm = matches.opt_present("emit-llvm");
|
||||
|
||||
if getopts::opt_present(matches, "v") ||
|
||||
getopts::opt_present(matches, "version") {
|
||||
if matches.opt_present("v") ||
|
||||
matches.opt_present("version") {
|
||||
rustc::version(args[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
let use_rust_path_hack = getopts::opt_present(matches, "r") ||
|
||||
getopts::opt_present(matches, "rust-path-hack");
|
||||
let use_rust_path_hack = matches.opt_present("r") ||
|
||||
matches.opt_present("rust-path-hack");
|
||||
|
||||
let linker = getopts::opt_maybe_str(matches, "linker");
|
||||
let link_args = getopts::opt_maybe_str(matches, "link-args");
|
||||
let cfgs = getopts::opt_strs(matches, "cfg") + getopts::opt_strs(matches, "c");
|
||||
let linker = matches.opt_str("linker");
|
||||
let link_args = matches.opt_str("link-args");
|
||||
let cfgs = matches.opt_strs("cfg") + matches.opt_strs("c");
|
||||
let mut user_supplied_opt_level = true;
|
||||
let opt_level = match getopts::opt_maybe_str(matches, "opt-level") {
|
||||
let opt_level = match matches.opt_str("opt-level") {
|
||||
Some(~"0") => session::No,
|
||||
Some(~"1") => session::Less,
|
||||
Some(~"2") => session::Default,
|
||||
Some(~"3") => session::Aggressive,
|
||||
_ if getopts::opt_present(matches, "O") => session::Default,
|
||||
_ if matches.opt_present("O") => session::Default,
|
||||
_ => {
|
||||
user_supplied_opt_level = false;
|
||||
session::No
|
||||
}
|
||||
};
|
||||
|
||||
let save_temps = getopts::opt_present(matches, "save-temps");
|
||||
let target = getopts::opt_maybe_str(matches, "target");
|
||||
let target_cpu = getopts::opt_maybe_str(matches, "target-cpu");
|
||||
let save_temps = matches.opt_present("save-temps");
|
||||
let target = matches.opt_str("target");
|
||||
let target_cpu = matches.opt_str("target-cpu");
|
||||
let experimental_features = {
|
||||
let strs = getopts::opt_strs(matches, "Z");
|
||||
if getopts::opt_present(matches, "Z") {
|
||||
let strs = matches.opt_strs("Z");
|
||||
if matches.opt_present("Z") {
|
||||
Some(strs)
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -41,7 +41,6 @@ pub fn main() {
|
|||
}
|
||||
|
||||
pub fn main_args(args: &[~str]) {
|
||||
use extra::getopts::*;
|
||||
use extra::getopts::groups::*;
|
||||
|
||||
let opts = ~[
|
||||
|
@ -56,20 +55,20 @@ pub fn main_args(args: &[~str]) {
|
|||
|
||||
let matches = getopts(args.tail(), opts).unwrap();
|
||||
|
||||
if opt_present(&matches, "h") || opt_present(&matches, "help") {
|
||||
if matches.opt_present("h") || matches.opt_present("help") {
|
||||
println(usage(args[0], opts));
|
||||
return;
|
||||
}
|
||||
|
||||
let libs = Cell::new(opt_strs(&matches, "L").map(|s| Path(*s)));
|
||||
let libs = Cell::new(matches.opt_strs("L").map(|s| Path(*s)));
|
||||
|
||||
let mut passes = if opt_present(&matches, "n") {
|
||||
let mut passes = if matches.opt_present("n") {
|
||||
~[]
|
||||
} else {
|
||||
~[~"collapse-docs", ~"clean-comments", ~"collapse-privacy" ]
|
||||
};
|
||||
|
||||
opt_strs(&matches, "a").map(|x| passes.push(x.clone()));
|
||||
matches.opt_strs("a").map(|x| passes.push(x.clone()));
|
||||
|
||||
if matches.free.len() != 1 {
|
||||
println(usage(args[0], opts));
|
||||
|
@ -99,7 +98,7 @@ pub fn main_args(args: &[~str]) {
|
|||
})
|
||||
}
|
||||
|
||||
for pname in opt_strs(&matches, "p").move_iter() {
|
||||
for pname in matches.opt_strs("p").move_iter() {
|
||||
pm.load_plugin(pname);
|
||||
}
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ fn parse_opts(argv: ~[~str]) -> Config {
|
|||
|
||||
match getopts::getopts(opt_args, opts) {
|
||||
Ok(ref m) => {
|
||||
return Config {stress: getopts::opt_present(m, "stress")}
|
||||
return Config {stress: m.opt_present("stress")}
|
||||
}
|
||||
Err(_) => { fail!(); }
|
||||
}
|
||||
|
|
|
@ -20,8 +20,8 @@ pub fn main() {
|
|||
|
||||
match getopts(args, opts) {
|
||||
Ok(ref m) =>
|
||||
assert!(!opt_present(m, "b")),
|
||||
Err(ref f) => fail!(fail_str((*f).clone()))
|
||||
assert!(!m.opt_present("b")),
|
||||
Err(ref f) => fail!((*f).clone().to_err_msg())
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue