gobanos / cargo-aoc

447 stars 47 forks source link

Add subcommand to submit solution #38

Open nindalf opened 4 years ago

nindalf commented 4 years ago

I think this would be helpful to add. @gobanos , what do you think?

gobanos commented 4 years ago

Should be quite easy to implement, and we already open a browser tab for criterion results, so it should be possible to open the puzzle page after submission.

nindalf commented 4 years ago

I think that might not even be necessary. When I tried to implement this, I figured it would be easier to store the result of cargo aoc in a file, and submit that value in a POST. We'd then parse the returned HTML to let the user if they got it right or not.

        let post_data = format!{"{{\"answer\": {}, \"level\": {}}}", solution, part.as_u8()};

        let mut response = client
            .post(&date.submit_url()) //  "https://adventofcode.com/{}/day/{}/answer",
            .body(post_data)
            .header(COOKIE, formated_token)
            .send()?;

I noticed the repo is undergoing some refactoring. Is that complete?

nindalf commented 4 years ago

Sorry if the previous comments weren't clear about this - I'm happy to implement this feature.