getopts: replaced base functions with those from group
This commit is contained in:
@@ -20,7 +20,7 @@ use std::os;
|
|||||||
use std::io;
|
use std::io;
|
||||||
use std::io::fs;
|
use std::io::fs;
|
||||||
|
|
||||||
use getopts::groups::{optopt, optflag, reqopt};
|
use getopts::{optopt, optflag, reqopt};
|
||||||
use extra::test;
|
use extra::test;
|
||||||
|
|
||||||
use common::config;
|
use common::config;
|
||||||
@@ -49,7 +49,7 @@ pub fn main() {
|
|||||||
|
|
||||||
pub fn parse_config(args: ~[~str]) -> config {
|
pub fn parse_config(args: ~[~str]) -> config {
|
||||||
|
|
||||||
let groups : ~[getopts::groups::OptGroup] =
|
let groups : ~[getopts::OptGroup] =
|
||||||
~[reqopt("", "compile-lib-path", "path to host shared libraries", "PATH"),
|
~[reqopt("", "compile-lib-path", "path to host shared libraries", "PATH"),
|
||||||
reqopt("", "run-lib-path", "path to target shared libraries", "PATH"),
|
reqopt("", "run-lib-path", "path to target shared libraries", "PATH"),
|
||||||
reqopt("", "rustc-path", "path to rustc to use for compiling", "PATH"),
|
reqopt("", "rustc-path", "path to rustc to use for compiling", "PATH"),
|
||||||
@@ -85,20 +85,20 @@ pub fn parse_config(args: ~[~str]) -> config {
|
|||||||
let args_ = args.tail();
|
let args_ = args.tail();
|
||||||
if args[1] == ~"-h" || args[1] == ~"--help" {
|
if args[1] == ~"-h" || args[1] == ~"--help" {
|
||||||
let message = format!("Usage: {} [OPTIONS] [TESTNAME...]", argv0);
|
let message = format!("Usage: {} [OPTIONS] [TESTNAME...]", argv0);
|
||||||
println!("{}", getopts::groups::usage(message, groups));
|
println!("{}", getopts::usage(message, groups));
|
||||||
println!("");
|
println!("");
|
||||||
fail!()
|
fail!()
|
||||||
}
|
}
|
||||||
|
|
||||||
let matches =
|
let matches =
|
||||||
&match getopts::groups::getopts(args_, groups) {
|
&match getopts::getopts(args_, groups) {
|
||||||
Ok(m) => m,
|
Ok(m) => m,
|
||||||
Err(f) => fail!("{}", f.to_err_msg())
|
Err(f) => fail!("{}", f.to_err_msg())
|
||||||
};
|
};
|
||||||
|
|
||||||
if matches.opt_present("h") || matches.opt_present("help") {
|
if matches.opt_present("h") || matches.opt_present("help") {
|
||||||
let message = format!("Usage: {} [OPTIONS] [TESTNAME...]", argv0);
|
let message = format!("Usage: {} [OPTIONS] [TESTNAME...]", argv0);
|
||||||
println!("{}", getopts::groups::usage(message, groups));
|
println!("{}", getopts::usage(message, groups));
|
||||||
println!("");
|
println!("");
|
||||||
fail!()
|
fail!()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
|
|
||||||
extern mod term;
|
extern mod term;
|
||||||
|
|
||||||
use getopts::groups;
|
|
||||||
use getopts;
|
use getopts;
|
||||||
use json::ToJson;
|
use json::ToJson;
|
||||||
use json;
|
use json;
|
||||||
@@ -209,29 +208,29 @@ pub struct TestOpts {
|
|||||||
/// Result of parsing the options.
|
/// Result of parsing the options.
|
||||||
pub type OptRes = Result<TestOpts, ~str>;
|
pub type OptRes = Result<TestOpts, ~str>;
|
||||||
|
|
||||||
fn optgroups() -> ~[getopts::groups::OptGroup] {
|
fn optgroups() -> ~[getopts::OptGroup] {
|
||||||
~[groups::optflag("", "ignored", "Run ignored tests"),
|
~[getopts::optflag("", "ignored", "Run ignored tests"),
|
||||||
groups::optflag("", "test", "Run tests and not benchmarks"),
|
getopts::optflag("", "test", "Run tests and not benchmarks"),
|
||||||
groups::optflag("", "bench", "Run benchmarks instead of tests"),
|
getopts::optflag("", "bench", "Run benchmarks instead of tests"),
|
||||||
groups::optflag("h", "help", "Display this message (longer with --help)"),
|
getopts::optflag("h", "help", "Display this message (longer with --help)"),
|
||||||
groups::optopt("", "save-metrics", "Location to save bench metrics",
|
getopts::optopt("", "save-metrics", "Location to save bench metrics",
|
||||||
"PATH"),
|
"PATH"),
|
||||||
groups::optopt("", "ratchet-metrics",
|
getopts::optopt("", "ratchet-metrics",
|
||||||
"Location to load and save metrics from. The metrics \
|
"Location to load and save metrics from. The metrics \
|
||||||
loaded are cause benchmarks to fail if they run too \
|
loaded are cause benchmarks to fail if they run too \
|
||||||
slowly", "PATH"),
|
slowly", "PATH"),
|
||||||
groups::optopt("", "ratchet-noise-percent",
|
getopts::optopt("", "ratchet-noise-percent",
|
||||||
"Tests within N% of the recorded metrics will be \
|
"Tests within N% of the recorded metrics will be \
|
||||||
considered as passing", "PERCENTAGE"),
|
considered as passing", "PERCENTAGE"),
|
||||||
groups::optopt("", "logfile", "Write logs to the specified file instead \
|
getopts::optopt("", "logfile", "Write logs to the specified file instead \
|
||||||
of stdout", "PATH"),
|
of stdout", "PATH"),
|
||||||
groups::optopt("", "test-shard", "run shard A, of B shards, worth of the testsuite",
|
getopts::optopt("", "test-shard", "run shard A, of B shards, worth of the testsuite",
|
||||||
"A.B")]
|
"A.B")]
|
||||||
}
|
}
|
||||||
|
|
||||||
fn usage(binary: &str, helpstr: &str) {
|
fn usage(binary: &str, helpstr: &str) {
|
||||||
let message = format!("Usage: {} [OPTIONS] [FILTER]", binary);
|
let message = format!("Usage: {} [OPTIONS] [FILTER]", binary);
|
||||||
println!("{}", groups::usage(message, optgroups()));
|
println!("{}", getopts::usage(message, optgroups()));
|
||||||
println!("");
|
println!("");
|
||||||
if helpstr == "help" {
|
if helpstr == "help" {
|
||||||
println!("{}", "\
|
println!("{}", "\
|
||||||
@@ -261,7 +260,7 @@ Test Attributes:
|
|||||||
pub fn parse_opts(args: &[~str]) -> Option<OptRes> {
|
pub fn parse_opts(args: &[~str]) -> Option<OptRes> {
|
||||||
let args_ = args.tail();
|
let args_ = args.tail();
|
||||||
let matches =
|
let matches =
|
||||||
match groups::getopts(args_, optgroups()) {
|
match getopts::getopts(args_, optgroups()) {
|
||||||
Ok(m) => m,
|
Ok(m) => m,
|
||||||
Err(f) => return Some(Err(f.to_err_msg()))
|
Err(f) => return Some(Err(f.to_err_msg()))
|
||||||
};
|
};
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -34,7 +34,7 @@ use std::io::fs;
|
|||||||
use std::io::MemReader;
|
use std::io::MemReader;
|
||||||
use std::os;
|
use std::os;
|
||||||
use std::vec;
|
use std::vec;
|
||||||
use getopts::groups::{optopt, optmulti, optflag, optflagopt};
|
use getopts::{optopt, optmulti, optflag, optflagopt};
|
||||||
use getopts;
|
use getopts;
|
||||||
use syntax::ast;
|
use syntax::ast;
|
||||||
use syntax::abi;
|
use syntax::abi;
|
||||||
@@ -992,7 +992,7 @@ pub fn parse_pretty(sess: Session, name: &str) -> PpMode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// rustc command line options
|
// rustc command line options
|
||||||
pub fn optgroups() -> ~[getopts::groups::OptGroup] {
|
pub fn optgroups() -> ~[getopts::OptGroup] {
|
||||||
~[
|
~[
|
||||||
optflag("c", "", "Compile and assemble, but do not link"),
|
optflag("c", "", "Compile and assemble, but do not link"),
|
||||||
optmulti("", "cfg", "Configure the compilation
|
optmulti("", "cfg", "Configure the compilation
|
||||||
@@ -1188,7 +1188,7 @@ mod test {
|
|||||||
use driver::driver::{build_configuration, build_session};
|
use driver::driver::{build_configuration, build_session};
|
||||||
use driver::driver::{build_session_options, optgroups};
|
use driver::driver::{build_session_options, optgroups};
|
||||||
|
|
||||||
use getopts::groups::getopts;
|
use getopts::getopts;
|
||||||
use syntax::attr;
|
use syntax::attr;
|
||||||
use syntax::attr::AttrMetaMethods;
|
use syntax::attr::AttrMetaMethods;
|
||||||
use syntax::diagnostic;
|
use syntax::diagnostic;
|
||||||
|
|||||||
@@ -51,7 +51,6 @@ use std::os;
|
|||||||
use std::str;
|
use std::str;
|
||||||
use std::task;
|
use std::task;
|
||||||
use std::vec;
|
use std::vec;
|
||||||
use getopts::groups;
|
|
||||||
use syntax::ast;
|
use syntax::ast;
|
||||||
use syntax::attr;
|
use syntax::attr;
|
||||||
use syntax::diagnostic::Emitter;
|
use syntax::diagnostic::Emitter;
|
||||||
@@ -142,7 +141,7 @@ pub fn usage(argv0: &str) {
|
|||||||
Additional help:
|
Additional help:
|
||||||
-W help Print 'lint' options and default settings
|
-W help Print 'lint' options and default settings
|
||||||
-Z help Print internal options for debugging rustc\n",
|
-Z help Print internal options for debugging rustc\n",
|
||||||
groups::usage(message, d::optgroups()));
|
getopts::usage(message, d::optgroups()));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn describe_warnings() {
|
pub fn describe_warnings() {
|
||||||
@@ -201,7 +200,7 @@ pub fn run_compiler(args: &[~str], demitter: @diagnostic::Emitter) {
|
|||||||
if args.is_empty() { usage(binary); return; }
|
if args.is_empty() { usage(binary); return; }
|
||||||
|
|
||||||
let matches =
|
let matches =
|
||||||
&match getopts::groups::getopts(args, d::optgroups()) {
|
&match getopts::getopts(args, d::optgroups()) {
|
||||||
Ok(m) => m,
|
Ok(m) => m,
|
||||||
Err(f) => {
|
Err(f) => {
|
||||||
d::early_error(demitter, f.to_err_msg());
|
d::early_error(demitter, f.to_err_msg());
|
||||||
|
|||||||
@@ -24,8 +24,7 @@ use middle::ty::{FnTyBase, FnMeta, FnSig};
|
|||||||
use util::ppaux::ty_to_str;
|
use util::ppaux::ty_to_str;
|
||||||
|
|
||||||
use extra::oldmap::HashMap;
|
use extra::oldmap::HashMap;
|
||||||
use getopts::groups::{optopt, optmulti, optflag, optflagopt, getopts};
|
use getopts::{optopt, optmulti, optflag, optflagopt, getopts};
|
||||||
use getopts::groups;
|
|
||||||
use getopts::opt_present;
|
use getopts::opt_present;
|
||||||
use syntax::codemap::DUMMY_SP;
|
use syntax::codemap::DUMMY_SP;
|
||||||
use syntax::parse::parse_crate_from_source_str;
|
use syntax::parse::parse_crate_from_source_str;
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ use std::str;
|
|||||||
use extra::json;
|
use extra::json;
|
||||||
use serialize::{Decodable, Encodable};
|
use serialize::{Decodable, Encodable};
|
||||||
use extra::time;
|
use extra::time;
|
||||||
use getopts::groups;
|
|
||||||
|
|
||||||
pub mod clean;
|
pub mod clean;
|
||||||
pub mod core;
|
pub mod core;
|
||||||
@@ -80,8 +79,8 @@ pub fn main() {
|
|||||||
std::os::set_exit_status(main_args(std::os::args()));
|
std::os::set_exit_status(main_args(std::os::args()));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn opts() -> ~[groups::OptGroup] {
|
pub fn opts() -> ~[getopts::OptGroup] {
|
||||||
use getopts::groups::*;
|
use getopts::*;
|
||||||
~[
|
~[
|
||||||
optflag("h", "help", "show this help message"),
|
optflag("h", "help", "show this help message"),
|
||||||
optflag("", "version", "print rustdoc's version"),
|
optflag("", "version", "print rustdoc's version"),
|
||||||
@@ -107,11 +106,11 @@ pub fn opts() -> ~[groups::OptGroup] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn usage(argv0: &str) {
|
pub fn usage(argv0: &str) {
|
||||||
println!("{}", groups::usage(format!("{} [options] <input>", argv0), opts()));
|
println!("{}", getopts::usage(format!("{} [options] <input>", argv0), opts()));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn main_args(args: &[~str]) -> int {
|
pub fn main_args(args: &[~str]) -> int {
|
||||||
let matches = match groups::getopts(args.tail(), opts()) {
|
let matches = match getopts::getopts(args.tail(), opts()) {
|
||||||
Ok(m) => m,
|
Ok(m) => m,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
println!("{}", err.to_err_msg());
|
println!("{}", err.to_err_msg());
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ use getopts::{optopt, getopts};
|
|||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
let args = ~[];
|
let args = ~[];
|
||||||
let opts = ~[optopt("b")];
|
let opts = ~[optopt("b", "", "something", "SMTHNG")];
|
||||||
|
|
||||||
match getopts(args, opts) {
|
match getopts(args, opts) {
|
||||||
Ok(ref m) =>
|
Ok(ref m) =>
|
||||||
|
|||||||
Reference in New Issue
Block a user