PyBites-Open-Source / eatlocal

This package helps users solve PyBites code challenges on their local machine.
MIT License
20 stars 9 forks source link

Feature: download and extract in the same operation #9

Closed JnyJny closed 2 years ago

JnyJny commented 2 years ago

I would like this kind of workflow:

$ cd $HOME/bites
$ eatlocal -d <BITENUMBER>
$ cd <BITENUMBER>
$ 

Where the download operation will both copy down the ZIP archive file and unzip it into the current working directory. It feels clunky to have to download and extract, I might as well call unzip directly rather than use the "-e" flag.

rhelmstedter commented 2 years ago

That is how I had it originally. I also like that workflow. @bbelderbos suggested that the operations be separated or we should rename the function something like download_and_extract. Is it worth it to create something like a -D flag that both downloads and extracts, -d that only downloads, and -e that only extracts? That way users have granular control over what they are doing?

JnyJny commented 2 years ago

I have some misgivings about two flags for downloading as it can be tough to remember which flag is which (but --help exists so it's not a huge problem). Adding flags also increases the complexity of the main function that has to decide what to do with all these options.

I'm trying to think of a case where I'd want to download a zip file but not extract it. I can think of a reason for not deleting the ZIP archive (restoring the bite if I didn't check in the original files before working on them and I need to start over).

I suspect what @bbelderbos was talking about was the function in eatlocal.py that download and extracted the bite and not the command line access to those functions.

rhelmstedter commented 2 years ago

ok, so starting on line 70 in main.py it would be something like:

 if download:
        download_bite(download, USERNAME, PASSWORD)
        extract_bite(download)
        raise typer.Exit()

Then add a feature that would give the option of not deleting the ZIP archive with the extract function? I like less clutter. Maybe a good compromise would be to download the ZIP into a zipped directory, extract them from there instead. That way there is less clutter but they aren't deleted completely.

bbelderbos commented 2 years ago

Great work guys, exciting project, it's linked now in the offline mode on Bites (premium feature).

Thanks Bob