Skip to content

Commit

Permalink
Merge pull request #47 from cole-miller/usage-to-stderr
Browse files Browse the repository at this point in the history
Print usage message to standard error, not standard output
  • Loading branch information
murarth committed Mar 15, 2021
2 parents 1502c3b + aa05d15 commit f5c4158
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ pub trait Options {
/// process will exit with status code `2`.
///
/// If the user supplies a help option, option usage will be printed to
/// `stdout` and the process will exit with status code `0`.
/// `stderr` and the process will exit with status code `0`.
///
/// Otherwise, the parsed options are returned.
fn parse_args_or_exit(style: ParsingStyle) -> Self where Self: Sized {
Expand Down Expand Up @@ -304,14 +304,14 @@ pub trait Options {
}
}

println!("Usage: {}{} [OPTIONS]", args[0], command_str);
println!();
println!("{}", command.self_usage());
eprintln!("Usage: {}{} [OPTIONS]", args[0], command_str);
eprintln!();
eprintln!("{}", command.self_usage());

if let Some(cmds) = command.self_command_list() {
println!();
println!("Available commands:");
println!("{}", cmds);
eprintln!();
eprintln!("Available commands:");
eprintln!("{}", cmds);
}

exit(0);
Expand All @@ -327,7 +327,7 @@ pub trait Options {
/// process will exit with status code `2`.
///
/// If the user supplies a help option, option usage will be printed to
/// `stdout` and the process will exit with status code `0`.
/// `stderr` and the process will exit with status code `0`.
///
/// Otherwise, the parsed options are returned.
fn parse_args_default_or_exit() -> Self where Self: Sized {
Expand Down Expand Up @@ -695,7 +695,7 @@ pub fn parse_args_default<T: Options>(args: &[String]) -> Result<T, Error> {
/// process will exit with status code `2`.
///
/// If the user supplies a help option, option usage will be printed to
/// `stdout` and the process will exit with status code `0`.
/// `stderr` and the process will exit with status code `0`.
///
/// Otherwise, the parsed options are returned.
///
Expand All @@ -713,7 +713,7 @@ pub fn parse_args_or_exit<T: Options>(style: ParsingStyle) -> T {
/// process will exit with status code `2`.
///
/// If the user supplies a help option, option usage will be printed to
/// `stdout` and the process will exit with status code `0`.
/// `stderr` and the process will exit with status code `0`.
///
/// Otherwise, the parsed options are returned.
///
Expand Down

0 comments on commit f5c4158

Please sign in to comment.