Skip to content

Commit bfc9a49

Browse files
committed
Print usage messages to rustc and rustdoc when invoked with no args. Close #1394.
1 parent 90ae3e3 commit bfc9a49

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/comp/driver/rustc.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ options:
6161

6262
fn main(args: [str]) {
6363
let args = args, binary = vec::shift(args);
64+
65+
if vec::len(args) == 0u { usage(binary); ret; }
66+
6467
let match =
6568
alt getopts::getopts(args, opts()) {
6669
ok(m) { m }

src/rustdoc/rustdoc.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,17 @@ fn doc_header(rd: rustdoc, name: str) {
179179
* argv[1]: crate file name",
180180
args(argv = "Command-line arguments.")
181181
)]
182+
182183
fn main(argv: [str]) {
183-
let sess = @{cm: codemap::new_codemap(), mutable next_id: 0};
184+
184185
let w = io::stdout();
186+
187+
if vec::len(argv) != 2u {
188+
w.write_str(#fmt("usage: %s <input>\n", argv[0]));
189+
ret;
190+
}
191+
192+
let sess = @{cm: codemap::new_codemap(), mutable next_id: 0};
185193
let rd = { ps: pprust::rust_printer(w), w: w };
186194
doc_header(rd, argv[1]);
187195
let p = parser::parse_crate_from_source_file(argv[1], [], sess);

0 commit comments

Comments
 (0)