aboutsummaryrefslogtreecommitdiff
path: root/src/comp/driver
diff options
context:
space:
mode:
authorGraydon Hoare <[email protected]>2011-05-05 12:03:23 -0700
committerGraydon Hoare <[email protected]>2011-05-05 13:09:43 -0700
commitf5f2f763395c3336b739866927a56edfbd1f204b (patch)
treee6a90e39b4c35cf6c1c6dedd0bbceec5183b637c /src/comp/driver
parentrustc: Link with intrinsics.bc; change intrinsics linkage to linkonce_odr (diff)
downloadrust-f5f2f763395c3336b739866927a56edfbd1f204b.tar.xz
rust-f5f2f763395c3336b739866927a56edfbd1f204b.zip
Add --help, --version and -v flags (not yet supporting GIT_REV env var, waiting on snapshot).
Diffstat (limited to 'src/comp/driver')
-rw-r--r--src/comp/driver/rustc.rs27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/comp/driver/rustc.rs b/src/comp/driver/rustc.rs
index dd10eee5..b7bca48a 100644
--- a/src/comp/driver/rustc.rs
+++ b/src/comp/driver/rustc.rs
@@ -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 @@ options:
--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");