From 565de31867d9ac73cdc5af413c5e0441ac26ae23 Mon Sep 17 00:00:00 2001 From: Andrew Chin Date: Fri, 10 Jan 2014 22:10:43 -0500 Subject: [PATCH] Re-implement --help in rustpkg Fixes #11423 --- src/librustpkg/parse_args.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/librustpkg/parse_args.rs b/src/librustpkg/parse_args.rs index 8f21c6d3bfa68..1051d475a8489 100644 --- a/src/librustpkg/parse_args.rs +++ b/src/librustpkg/parse_args.rs @@ -36,7 +36,8 @@ pub struct ParseResult { /// Parses command line arguments of rustpkg. /// Returns a triplet (command, remaining_args, context) pub fn parse_args(args: &[~str]) -> Result { - let opts = ~[ getopts::optflag("no-link"), + let opts = ~[ getopts::optflag("h"), getopts::optflag("help"), + getopts::optflag("no-link"), getopts::optflag("no-trans"), // n.b. Ignores different --pretty options for now getopts::optflag("pretty"), @@ -71,6 +72,12 @@ pub fn parse_args(args: &[~str]) -> Result { let pretty = matches.opt_present("pretty"); let emit_llvm = matches.opt_present("emit-llvm"); + if matches.opt_present("h") || + matches.opt_present("help") { + usage::general(); + return Err(0); + } + if matches.opt_present("v") || matches.opt_present("version") { version(args[0]);