提交 f5f2f763 编写于 作者: G Graydon Hoare

Add --help, --version and -v flags (not yet supporting GIT_REV env var, waiting on snapshot).

上级 a74feaf1
......@@ -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");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册