Skip to content

Commit

Permalink
Fix Cli Return Code on --help for ethkey, ethstore & whisper (#8863)
Browse files Browse the repository at this point in the history
Docopt handles `--help` automatically for us, however we've handled those
Errors the same as all others: by exiting with Return Code `1`, which is wrong
for a totally appropriate a quit on `--help`. Fortunately `docopt:Error`
provides an `exit` helper function that discriminates properly between fatal
and non-fatal errors and exist appropriately.

This patch makes sure we use that handy function in case we encounter such an
error in the CLI of ethkey, ethstore and whisper. Thus those are now giving
the appropriate Return code on `--help`.

fixes #8851
  • Loading branch information
gnunicorn authored and tavakyan committed Jun 14, 2018
1 parent 3dc770b commit 9cbb07a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion ethkey/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,11 @@ fn main() {

match execute(env::args()) {
Ok(ok) => println!("{}", ok),
Err(Error::Docopt(ref e)) => e.exit(),
Err(err) => {
println!("{}", err);
process::exit(1);
},
}
}
}

Expand Down
1 change: 1 addition & 0 deletions ethstore/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ fn main() {

match execute(env::args()) {
Ok(result) => println!("{}", result),
Err(Error::Docopt(ref e)) => e.exit(),
Err(err) => {
println!("{}", err);
process::exit(1);
Expand Down
5 changes: 3 additions & 2 deletions whisper/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,12 @@ fn main() {
Ok(_) => {
println!("whisper-cli terminated");
process::exit(1);
}
},
Err(Error::Docopt(ref e)) => e.exit(),
Err(err) => {
println!("{}", err);
process::exit(1);
},
}
}
}

Expand Down

0 comments on commit 9cbb07a

Please sign in to comment.