Print usage messages to rustc and rustdoc when invoked with no args. Close #1394.

This commit is contained in:
Graydon Hoare 2011-12-30 15:26:49 -08:00
parent 90ae3e3168
commit bfc9a499c2
2 changed files with 12 additions and 1 deletions

View File

@ -61,6 +61,9 @@ options:
fn main(args: [str]) {
let args = args, binary = vec::shift(args);
if vec::len(args) == 0u { usage(binary); ret; }
let match =
alt getopts::getopts(args, opts()) {
ok(m) { m }

View File

@ -179,9 +179,17 @@ fn doc_header(rd: rustdoc, name: str) {
* argv[1]: crate file name",
args(argv = "Command-line arguments.")
)]
fn main(argv: [str]) {
let sess = @{cm: codemap::new_codemap(), mutable next_id: 0};
let w = io::stdout();
if vec::len(argv) != 2u {
w.write_str(#fmt("usage: %s <input>\n", argv[0]));
ret;
}
let sess = @{cm: codemap::new_codemap(), mutable next_id: 0};
let rd = { ps: pprust::rust_printer(w), w: w };
doc_header(rd, argv[1]);
let p = parser::parse_crate_from_source_file(argv[1], [], sess);