Skip to content

Commit

Permalink
Merge pull request #1 from djipko/main
Browse files Browse the repository at this point in the history
Return a non-zero exit-code on error
  • Loading branch information
scarvalhojr authored Nov 30, 2021
2 parents 9e8b2c4 + c403b6a commit c468277
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::process::exit;

const SESSION_COOKIE_FILE: &str = ".adventofcode.session";

fn main() {
fn main() -> Result<(), String> {
let args = parse_args();
let year = if args.is_present("year") {
Some(value_t_or_exit!(args, "year", PuzzleYear))
Expand All @@ -26,7 +26,7 @@ fn main() {

let session_cookie = read_session_cookie(args.value_of("session"));

let result = match args.value_of("command").unwrap() {
match args.value_of("command").unwrap() {
cmd if cmd == "download" || cmd == "d" => {
let filename = args.value_of("file").unwrap();
download_input(&session_cookie, year, day, filename)
Expand All @@ -40,10 +40,6 @@ fn main() {
read_puzzle(&session_cookie, year, day)
}
_ => unreachable!(),
};

if let Err(err) = result {
eprintln!("Error: {}", err);
}
}

Expand Down

0 comments on commit c468277

Please sign in to comment.