提交 67fa90e4 编写于 作者: B Brian Anderson

Print 'rustc' and 'rustdoc' as the command name for --version

Instead of just blindly printing arg[0], use a constant string.
Partial fix for #13582
上级 2a7a3919
...@@ -104,17 +104,17 @@ fn run_compiler(args: &[~str]) { ...@@ -104,17 +104,17 @@ fn run_compiler(args: &[~str]) {
driver::compile_input(sess, cfg, &input, &odir, &ofile); driver::compile_input(sess, cfg, &input, &odir, &ofile);
} }
pub fn version(argv0: &str) { pub fn version(command: &str) {
let vers = match option_env!("CFG_VERSION") { let vers = match option_env!("CFG_VERSION") {
Some(vers) => vers, Some(vers) => vers,
None => "unknown version" None => "unknown version"
}; };
println!("{} {}", argv0, vers); println!("{} {}", command, vers);
println!("host: {}", driver::host_triple()); println!("host: {}", driver::host_triple());
} }
fn usage(argv0: &str) { fn usage() {
let message = format!("Usage: {} [OPTIONS] INPUT", argv0); let message = format!("Usage: rustc [OPTIONS] INPUT");
println!("{}\n\ println!("{}\n\
Additional help: Additional help:
-C help Print codegen options -C help Print codegen options
...@@ -192,9 +192,10 @@ fn describe_codegen_flags() { ...@@ -192,9 +192,10 @@ fn describe_codegen_flags() {
/// should continue, returns a getopts::Matches object parsed from args, otherwise /// should continue, returns a getopts::Matches object parsed from args, otherwise
/// returns None. /// returns None.
pub fn handle_options(mut args: Vec<~str>) -> Option<getopts::Matches> { pub fn handle_options(mut args: Vec<~str>) -> Option<getopts::Matches> {
let binary = args.shift().unwrap(); // Throw away the first argument, the name of the binary
let _binary = args.shift().unwrap();
if args.is_empty() { usage(binary); return None; } if args.is_empty() { usage(); return None; }
let matches = let matches =
match getopts::getopts(args.as_slice(), config::optgroups().as_slice()) { match getopts::getopts(args.as_slice(), config::optgroups().as_slice()) {
...@@ -205,7 +206,7 @@ pub fn handle_options(mut args: Vec<~str>) -> Option<getopts::Matches> { ...@@ -205,7 +206,7 @@ pub fn handle_options(mut args: Vec<~str>) -> Option<getopts::Matches> {
}; };
if matches.opt_present("h") || matches.opt_present("help") { if matches.opt_present("h") || matches.opt_present("help") {
usage(binary); usage();
return None; return None;
} }
...@@ -234,7 +235,7 @@ pub fn handle_options(mut args: Vec<~str>) -> Option<getopts::Matches> { ...@@ -234,7 +235,7 @@ pub fn handle_options(mut args: Vec<~str>) -> Option<getopts::Matches> {
} }
if matches.opt_present("v") || matches.opt_present("version") { if matches.opt_present("v") || matches.opt_present("version") {
version(binary); version("rustc");
return None; return None;
} }
......
...@@ -153,7 +153,7 @@ pub fn main_args(args: &[StrBuf]) -> int { ...@@ -153,7 +153,7 @@ pub fn main_args(args: &[StrBuf]) -> int {
usage(args[0].as_slice()); usage(args[0].as_slice());
return 0; return 0;
} else if matches.opt_present("version") { } else if matches.opt_present("version") {
rustc::driver::version(args[0].as_slice()); rustc::driver::version("rustdoc");
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册