Skip to content

Commit 0068bd7

Browse files
committed
auto merge of #8131 : Seldaek/rust/getopt_usage_newline, r=brson
It makes things ugly when the last thing you print is the usage() output, resulting in something like: ``` $ rust run foo.rs -h Lala Options: -h --help display this help and exit -V --version output version information and exit $ prompt ```
2 parents 576f395 + f7ebab4 commit 0068bd7

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

src/compiletest/compiletest.rs

+2
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ pub fn parse_config(args: ~[~str]) -> config {
8585
if args[1] == ~"-h" || args[1] == ~"--help" {
8686
let message = fmt!("Usage: %s [OPTIONS] [TESTNAME...]", argv0);
8787
println(getopts::groups::usage(message, groups));
88+
println("");
8889
fail!()
8990
}
9091

@@ -97,6 +98,7 @@ pub fn parse_config(args: ~[~str]) -> config {
9798
if getopts::opt_present(matches, "h") || getopts::opt_present(matches, "help") {
9899
let message = fmt!("Usage: %s [OPTIONS] [TESTNAME...]", argv0);
99100
println(getopts::groups::usage(message, groups));
101+
println("");
100102
fail!()
101103
}
102104

src/libextra/getopts.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ pub mod groups {
680680
return brief.to_owned() +
681681
"\n\nOptions:\n" +
682682
rows.collect::<~[~str]>().connect("\n") +
683-
"\n\n";
683+
"\n";
684684
}
685685

686686
/** Splits a string into substrings with possibly internal whitespace,
@@ -1463,7 +1463,6 @@ Options:
14631463
-k --kiwi Desc
14641464
-p [VAL] Desc
14651465
-l VAL Desc
1466-
14671466
";
14681467
14691468
let generated_usage = groups::usage("Usage: fruits", optgroups);
@@ -1492,7 +1491,6 @@ Options:
14921491
-k --kiwi This is a long description which won't be wrapped..+..
14931492
-a --apple This is a long description which _will_ be
14941493
wrapped..+..
1495-
14961494
";
14971495
14981496
let usage = groups::usage("Usage: fruits", optgroups);

src/libextra/test.rs

+1
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ fn optgroups() -> ~[getopts::groups::OptGroup] {
191191
fn usage(binary: &str, helpstr: &str) -> ! {
192192
let message = fmt!("Usage: %s [OPTIONS] [FILTER]", binary);
193193
println(groups::usage(message, optgroups()));
194+
println("");
194195
if helpstr == "help" {
195196
println("\
196197
The FILTER is matched against the name of all tests to run, and if any tests

0 commit comments

Comments
 (0)