diff --git a/mk/crates.mk b/mk/crates.mk index ea573b9db8d21..65fb242576452 100644 --- a/mk/crates.mk +++ b/mk/crates.mk @@ -49,19 +49,20 @@ # automatically generated for all stage/host/target combinations. ################################################################################ -TARGET_CRATES := std extra green rustuv native flate arena glob term semver uuid serialize sync +TARGET_CRATES := std extra green rustuv native flate arena glob term semver \ + uuid serialize sync getopts HOST_CRATES := syntax rustc rustdoc CRATES := $(TARGET_CRATES) $(HOST_CRATES) TOOLS := compiletest rustdoc rustc DEPS_std := native:rustrt -DEPS_extra := std serialize sync term +DEPS_extra := std term sync serialize getopts DEPS_green := std DEPS_rustuv := std native:uv native:uv_support DEPS_native := std DEPS_syntax := std extra term serialize -DEPS_rustc := syntax native:rustllvm flate arena serialize sync -DEPS_rustdoc := rustc native:sundown serialize sync +DEPS_rustc := syntax native:rustllvm flate arena serialize sync getopts +DEPS_rustdoc := rustc native:sundown serialize sync getopts DEPS_flate := std native:miniz DEPS_arena := std extra DEPS_glob := std @@ -70,8 +71,9 @@ DEPS_term := std DEPS_semver := std DEPS_uuid := std serialize DEPS_sync := std +DEPS_getopts := std -TOOL_DEPS_compiletest := extra green rustuv +TOOL_DEPS_compiletest := extra green rustuv getopts TOOL_DEPS_rustdoc := rustdoc green rustuv TOOL_DEPS_rustc := rustc green rustuv TOOL_SOURCE_compiletest := $(S)src/compiletest/compiletest.rs diff --git a/src/compiletest/compiletest.rs b/src/compiletest/compiletest.rs index 8896b44f06008..ff427ff0f5969 100644 --- a/src/compiletest/compiletest.rs +++ b/src/compiletest/compiletest.rs @@ -14,13 +14,13 @@ #[deny(warnings)]; extern mod extra; +extern mod getopts; use std::os; use std::io; use std::io::fs; -use extra::getopts; -use extra::getopts::groups::{optopt, optflag, reqopt}; +use getopts::groups::{optopt, optflag, reqopt}; use extra::test; use common::config; diff --git a/src/doc/index.md b/src/doc/index.md index 54b8b484693a9..39dc196b6a051 100644 --- a/src/doc/index.md +++ b/src/doc/index.md @@ -39,6 +39,7 @@ li {list-style-type: none; } * [The `arena` allocation library](arena/index.html) * [The `flate` compression library](flate/index.html) +* [The `getopts` argument parsing library](getopts/index.html) * [The `glob` file path matching library](glob/index.html) * [The `semver` version collation library](semver/index.html) * [The `serialize` value encoding/decoding library](serialize/index.html) diff --git a/src/libextra/lib.rs b/src/libextra/lib.rs index 37b4d3cc524be..97c38a59af85b 100644 --- a/src/libextra/lib.rs +++ b/src/libextra/lib.rs @@ -73,7 +73,6 @@ pub mod lru_cache; // And ... other stuff pub mod url; -pub mod getopts; pub mod json; pub mod tempfile; pub mod time; diff --git a/src/libextra/test.rs b/src/libextra/test.rs index c4d27b25b5503..b412138bff52a 100644 --- a/src/libextra/test.rs +++ b/src/libextra/test.rs @@ -17,8 +17,8 @@ extern mod term; -use getopts; use getopts::groups; +use getopts; use json::ToJson; use json; use serialize::Decodable; diff --git a/src/libextra/getopts.rs b/src/libgetopts/lib.rs similarity index 99% rename from src/libextra/getopts.rs rename to src/libgetopts/lib.rs index f29caec5d3307..e1c0df294f73e 100644 --- a/src/libextra/getopts.rs +++ b/src/libgetopts/lib.rs @@ -30,8 +30,8 @@ //! file name following `-o`, and accepts both `-h` and `--help` as optional flags. //! //! ~~~{.rust} -//! extern mod extra; -//! use extra::getopts::{optopt,optflag,getopts,Opt}; +//! extern mod getopts; +//! use getopts::{optopt,optflag,getopts,Opt}; //! use std::os; //! //! fn do_work(inp: &str, out: Option<~str>) { @@ -77,6 +77,14 @@ //! } //! ~~~ +#[crate_id = "getopts#0.10-pre"]; +#[crate_type = "rlib"]; +#[crate_type = "dylib"]; +#[license = "MIT/ASL2"]; +#[allow(missing_doc)]; + +#[feature(globs)]; + use std::cmp::Eq; use std::result::{Err, Ok}; use std::result; @@ -519,8 +527,8 @@ pub fn getopts(args: &[~str], opts: &[Opt]) -> Result { /// A module which provides a way to specify descriptions and /// groups of short and long option names, together. pub mod groups { - use getopts::{HasArg, Long, Maybe, Multi, No, Occur, Opt, Optional, Req}; - use getopts::{Short, Yes}; + use super::{HasArg, Long, Maybe, Multi, No, Occur, Opt, Optional, Req}; + use super::{Short, Yes}; /// One group of options, e.g., both -h and --help, along with /// their shared description and properties. @@ -671,8 +679,8 @@ pub mod groups { } /// Parse command line args with the provided long format options. - pub fn getopts(args: &[~str], opts: &[OptGroup]) -> ::getopts::Result { - ::getopts::getopts(args, opts.map(|x| x.long_to_short())) + pub fn getopts(args: &[~str], opts: &[OptGroup]) -> super::Result { + super::getopts(args, opts.map(|x| x.long_to_short())) } fn format_option(opt: &OptGroup) -> ~str { @@ -901,8 +909,8 @@ pub mod groups { #[cfg(test)] mod tests { - use getopts::groups::OptGroup; - use getopts::*; + use super::groups::OptGroup; + use super::*; use std::result::{Err, Ok}; use std::result; diff --git a/src/librustc/driver/driver.rs b/src/librustc/driver/driver.rs index c3b851b76ac04..1d99faa751160 100644 --- a/src/librustc/driver/driver.rs +++ b/src/librustc/driver/driver.rs @@ -34,8 +34,8 @@ use std::io::fs; use std::io::MemReader; use std::os; use std::vec; -use extra::getopts::groups::{optopt, optmulti, optflag, optflagopt}; -use extra::getopts; +use getopts::groups::{optopt, optmulti, optflag, optflagopt}; +use getopts; use syntax::ast; use syntax::abi; use syntax::attr; @@ -1188,7 +1188,7 @@ mod test { use driver::driver::{build_configuration, build_session}; use driver::driver::{build_session_options, optgroups}; - use extra::getopts::groups::getopts; + use getopts::groups::getopts; use syntax::attr; use syntax::attr::AttrMetaMethods; use syntax::diagnostic; diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index 52ddc8c810888..c675de0d528c1 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -37,6 +37,7 @@ extern mod arena; extern mod syntax; extern mod serialize; extern mod sync; +extern mod getopts; use back::link; use driver::session; @@ -50,8 +51,7 @@ use std::os; use std::str; use std::task; use std::vec; -use extra::getopts::groups; -use extra::getopts; +use getopts::groups; use syntax::ast; use syntax::attr; use syntax::diagnostic::Emitter; diff --git a/src/librustc/middle/typeck/infer/test.rs b/src/librustc/middle/typeck/infer/test.rs index 6ac4c5ff395ce..28b10e881cd9a 100644 --- a/src/librustc/middle/typeck/infer/test.rs +++ b/src/librustc/middle/typeck/infer/test.rs @@ -23,12 +23,10 @@ use middle::lang_items::{LanguageItems, language_items}; use middle::ty::{FnTyBase, FnMeta, FnSig}; use util::ppaux::ty_to_str; -use extra::getopts::groups::{optopt, optmulti, optflag, optflagopt, getopts}; -use extra::getopts::groups; -use extra::getopts::{opt_present}; -use extra::getopts; -use extra::getopts; use extra::oldmap::HashMap; +use getopts::groups::{optopt, optmulti, optflag, optflagopt, getopts}; +use getopts::groups; +use getopts::opt_present; use syntax::codemap::DUMMY_SP; use syntax::parse::parse_crate_from_source_str; use syntax::{ast, attr, parse}; diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 7256e8923fa87..48828a1ed06f4 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -20,16 +20,16 @@ extern mod rustc; extern mod extra; extern mod serialize; extern mod sync; +extern mod getopts; use std::local_data; use std::io; use std::io::{File, MemWriter}; use std::str; -use extra::getopts; -use extra::getopts::groups; use extra::json; use serialize::{Decodable, Encodable}; use extra::time; +use getopts::groups; pub mod clean; pub mod core; @@ -81,7 +81,7 @@ pub fn main() { } pub fn opts() -> ~[groups::OptGroup] { - use extra::getopts::groups::*; + use getopts::groups::*; ~[ optflag("h", "help", "show this help message"), optflag("", "version", "print rustdoc's version"), diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index 28e62f8fb299a..12f2f2ca9361c 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -16,11 +16,11 @@ use std::run; use std::str; use extra::tempfile::TempDir; -use extra::getopts; use extra::test; use rustc::driver::driver; use rustc::driver::session; use rustc::metadata::creader::Loader; +use getopts; use syntax::diagnostic; use syntax::parse; diff --git a/src/test/bench/shootout-pfib.rs b/src/test/bench/shootout-pfib.rs index 040c8526ee04f..45fc398ebeb80 100644 --- a/src/test/bench/shootout-pfib.rs +++ b/src/test/bench/shootout-pfib.rs @@ -19,8 +19,9 @@ */ extern mod extra; +extern mod getopts; -use extra::{time, getopts}; +use extra::time; use std::os; use std::result::{Ok, Err}; use std::task; diff --git a/src/test/run-pass/getopts_ref.rs b/src/test/run-pass/getopts_ref.rs index bfc140065655f..837f808274238 100644 --- a/src/test/run-pass/getopts_ref.rs +++ b/src/test/run-pass/getopts_ref.rs @@ -10,9 +10,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern mod extra; +extern mod getopts; -use extra::getopts::{optopt, getopts}; +use getopts::{optopt, getopts}; pub fn main() { let args = ~[];