advent-of-code-rust icon indicating copy to clipboard operation
advent-of-code-rust copied to clipboard

Read only part 2

Open Ascyii opened this issue 2 years ago • 6 comments

It would be nice to have a flag for reading only part 2 of a puzzle.

Ascyii avatar Dec 06 '23 17:12 Ascyii

The underlying aoc-cli does not have a flag for it. It should be simple enough to add this on our side, but I'm wondering if the upstream project wouldn't benefit from this as well.

Anyway, I would accept a PR that adds this on our side as well.

fspoettel avatar Dec 06 '23 18:12 fspoettel

Something I noticed is that once you have completed part 1, the part 2 is not saved automatically to the puzzle file. Doing cargo read <problem_no> after you have completed part 1 makes use of the aoc website/api and reads the puzzle from there but after that it does not save it to the puzzles file again. The puzzle file stays outdated

AV3RG avatar Apr 12 '24 12:04 AV3RG

Something I noticed is that once you have completed part 1, the part 2 is not saved automatically to the puzzle file. Doing cargo read <problem_no> after you have completed part 1 makes use of the aoc website/api and reads the puzzle from there but after that it does not save it to the puzzles file again. The puzzle file stays outdated

After looking into this issue seems to be because of the way aoc_cli handles the read command. In the code of the template we are using this code

pub fn read(day: Day) -> Result<Output, AocCommandError> {
    let puzzle_path = get_puzzle_path(day);

    let args = build_args(
        "read",
        &[
            "--description-only".into(),
            "--puzzle-file".into(),
            puzzle_path,
        ],
        day,
    );

    call_aoc_cli(&args)
}

But the issue is that the puzzle-file and description-only arguments don't mean anything for aoc-cli in this particular command, this command always uses the api and directly displays the puzzle from there. aoc read --day 2 --puzzle-file test.md Running this command does not make any test.md file and it looks like the puzzle-file argument is only for the download command. The code for running the read command inside aoc-cli does not show any use for this argument. This is something that should also be handled on our end and maybe on aoc-cli too if they feel like going in this direction

AV3RG avatar Apr 12 '24 12:04 AV3RG