Skip to content

Commit

Permalink
feat: add --download flag to scaffold (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
fspoettel authored Dec 5, 2023
1 parent 47e4f22 commit 3260b73
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ Every [solution](https://github.com/fspoettel/advent-of-code-rust/blob/main/src/
### Download input & description for a day

> [!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
# example: `cargo download 1`
Expand Down
9 changes: 8 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ mod args {
},
Scaffold {
day: Day,
download: bool,
},
Solve {
day: Day,
Expand Down Expand Up @@ -44,6 +45,7 @@ mod args {
},
Some("scaffold") => AppArguments::Scaffold {
day: args.free_from_str()?,
download: args.contains("--download"),
},
Some("solve") => AppArguments::Solve {
day: args.free_from_str()?,
Expand Down Expand Up @@ -80,7 +82,12 @@ fn main() {
AppArguments::All { release, time } => all::handle(release, time),
AppArguments::Download { day } => download::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 {
day,
release,
Expand Down

0 comments on commit 3260b73

Please sign in to comment.