Refactor CLI + Credential storing tools + Input downloading tools #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR implements my refactoring of the application using CLAP. 🎬
We now have 2 subcommands (cargo aoc credentials and cargo aoc input) that will get matched by CLAP and handled correctly in the
AOCApp
struct (app.rs
), which is basically just a wrapper for the core functions, and a place to store the state of the app in, if it ever gets any (more?) complex.Credentials are handled using the
CredentialsManager
struct incredentials.rs
. The error handling looks good to me, at least we have cool error messages, and no unexpected crash.Implemented an
AOCDate
struct indate.rs
- that actually might be better off being placed inaoc_runner_internal
💁♀️ - It's meant to handle the day and year so we can grab the input from AoC's website.The Credentials command stores the credentials in a file located next to the binary of
cargo aoc
. Potential users wouldn't like their token being accidentally exposed in their working directory, lol.The Input command sends a GET query, setting the cookie beforehand. It then creates the file-tree and stores the result of the query in a file, thus generating
input/{year}/day_{day}.txt
--
Also, added a small yet cool
README.md
to give users a hint on how to use this wonderful tool 👍