mirror of
https://github.com/rust-lang/rust
synced 2024-11-02 14:59:06 +00:00
Add --help, --version and -v flags (not yet supporting GIT_REV env var, waiting on snapshot).
This commit is contained in:
parent
a74feaf159
commit
f5f2f76339
1 changed files with 23 additions and 4 deletions
|
@ -126,10 +126,21 @@ fn pretty_print_input(session.session sess,
|
|||
pretty.pprust.print_file(crate.node.module, input, std.io.stdout());
|
||||
}
|
||||
|
||||
fn version(str argv0) {
|
||||
auto git_rev = ""; // when snapshotted to extenv: #env("GIT_REV");
|
||||
if (_str.byte_len(git_rev) != 0u) {
|
||||
git_rev = #fmt(" (git: %s)", git_rev);
|
||||
}
|
||||
io.stdout().write_str(#fmt("%s prerelease%s\n", argv0, git_rev));
|
||||
}
|
||||
|
||||
fn usage(str argv0) {
|
||||
io.stdout().write_str(#fmt("usage: %s [options] <input>\n", argv0) + "
|
||||
options:
|
||||
|
||||
-h --help display this message
|
||||
-v --version print version info and exit
|
||||
|
||||
-o <filename> write output to <filename>
|
||||
--glue generate glue.bc file
|
||||
--shared compile a shared-library crate
|
||||
|
@ -146,8 +157,7 @@ fn usage(str argv0) {
|
|||
--save-temps write intermediate files in addition to normal output
|
||||
--time-passes time the individual phases of the compiler
|
||||
--sysroot <path> override the system root (default: rustc's directory)
|
||||
--no-typestate don't run the typestate pass (unsafe!)
|
||||
-h display this message\n\n");
|
||||
--no-typestate don't run the typestate pass (unsafe!)\n\n");
|
||||
}
|
||||
|
||||
fn get_os() -> session.os {
|
||||
|
@ -173,7 +183,9 @@ fn main(vec[str] args) {
|
|||
uint_type = common.ty_u32,
|
||||
float_type = common.ty_f64);
|
||||
|
||||
auto opts = vec(optflag("h"), optflag("glue"),
|
||||
auto opts = vec(optflag("h"), optflag("help"),
|
||||
optflag("v"), optflag("version"),
|
||||
optflag("glue"),
|
||||
optflag("pretty"), optflag("ls"), optflag("parse-only"),
|
||||
optflag("O"), optflag("shared"), optmulti("L"),
|
||||
optflag("S"), optflag("c"), optopt("o"), optopt("g"),
|
||||
|
@ -189,11 +201,18 @@ fn main(vec[str] args) {
|
|||
}
|
||||
case (GetOpts.success(?m)) { match = m; }
|
||||
}
|
||||
if (opt_present(match, "h")) {
|
||||
if (opt_present(match, "h") ||
|
||||
opt_present(match, "help")) {
|
||||
usage(binary);
|
||||
ret;
|
||||
}
|
||||
|
||||
if (opt_present(match, "v") ||
|
||||
opt_present(match, "version")) {
|
||||
version(binary);
|
||||
ret;
|
||||
}
|
||||
|
||||
auto pretty = opt_present(match, "pretty");
|
||||
auto ls = opt_present(match, "ls");
|
||||
auto glue = opt_present(match, "glue");
|
||||
|
|
Loading…
Reference in a new issue