feat: add --download flag to scaffold (#46)

This commit is contained in:
Felix Spöttel 2023-12-05 22:35:32 +01:00 committed by GitHub
parent 47e4f227bd
commit 3260b731be
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View file

@ -60,7 +60,9 @@ Every [solution](https://github.com/fspoettel/advent-of-code-rust/blob/main/src/
### Download input & description for a day ### Download input & description for a day
> [!IMPORTANT] > [!IMPORTANT]
> This command requires [installing the aoc-cli crate](#configure-aoc-cli-integration). > This requires [installing the aoc-cli crate](#configure-aoc-cli-integration).
You can automatically download puzzle inputs and description by either appending the `--download` flag to `scaffold` (e.g. `cargo scaffold 4 --download`) or with the separate `download` command:
```sh ```sh
# example: `cargo download 1` # example: `cargo download 1`

View file

@ -15,6 +15,7 @@ mod args {
}, },
Scaffold { Scaffold {
day: Day, day: Day,
download: bool,
}, },
Solve { Solve {
day: Day, day: Day,
@ -44,6 +45,7 @@ mod args {
}, },
Some("scaffold") => AppArguments::Scaffold { Some("scaffold") => AppArguments::Scaffold {
day: args.free_from_str()?, day: args.free_from_str()?,
download: args.contains("--download"),
}, },
Some("solve") => AppArguments::Solve { Some("solve") => AppArguments::Solve {
day: args.free_from_str()?, day: args.free_from_str()?,
@ -80,7 +82,12 @@ fn main() {
AppArguments::All { release, time } => all::handle(release, time), AppArguments::All { release, time } => all::handle(release, time),
AppArguments::Download { day } => download::handle(day), AppArguments::Download { day } => download::handle(day),
AppArguments::Read { day } => read::handle(day), AppArguments::Read { day } => read::handle(day),
AppArguments::Scaffold { day } => scaffold::handle(day), AppArguments::Scaffold { day, download } => {
scaffold::handle(day);
if download {
download::handle(day);
}
}
AppArguments::Solve { AppArguments::Solve {
day, day,
release, release,