diff --git a/download.py b/download.py index 672b33f..6dde19f 100644 --- a/download.py +++ b/download.py @@ -195,6 +195,10 @@ def wait_for_next_puzzle(): spinner.ok("🎄 ") +def ensure_dir(path: pathlib.Path): + os.makedirs(path) + + def setup_logs(verbose: bool): coloredlogs.install( level=logging.DEBUG if verbose else logging.INFO, @@ -224,6 +228,13 @@ class FetchCommand(click.Command): help="The output location of the puzzle inputs", default=".", ) +@click.option( + "-O", + "output_dir_make", + type=pathlib.Path, + help="The output location of the puzzle inputs. Unlike -o, this will create the directory for you", + default=None, +) @click.option( "--token-file", "token_path", @@ -251,6 +262,7 @@ def main( passed_token: str, token_path: pathlib.Path, output_dir: pathlib.Path, + output_dir_make: Optional[pathlib.Path], wait: bool, input_only: bool, interactive: bool, @@ -274,6 +286,10 @@ def main( if wait: wait_for_next_puzzle() + if output_dir_make: + ensure_dir(output_dir_make) + output_dir = output_dir_make + specified_date = PuzzleDate(year=year, day=day) if day and year else None date_to_fetch = specified_date or PuzzleDate.get_latest() step = None