I see the value of use_course(), but I sometimes want to download a ZIP file that is not an RStudio project, and use it. For example, a ZIP file that lives somewhere online that contains some shapefiles that I want to use.
So how would you feel about a PR that includes use_zip(), which is just like use_course() except that it returns an fs_path to the unzipped directory? use_course() could would then call use_zip() to maintain its current functionality.
I see the value of use_course(), but I sometimes want to download a ZIP file that is not an RStudio project
This already works. Just use it on a ZIP archive that does not contain an Rproj file.
For example, try this: use_course("rstd.io/wtf-explore-libraries")
But I suspect we are misunderstanding each other.
OK. But indulge me by considering three things:
use_course() has a narrow scope, so for example this doesn't work: usethis::use_course("https://www.fueleconomy.gov/feg/epadata/16data.zip")
#> ✔ Downloading 'https://www.fueleconomy.gov/feg/epadata/16data.zip'
#>
Downloaded: 0.02 MB (2%)
Downloaded: 0.02 MB (2%)
Downloaded: 0.03 MB (3%)
...
Downloaded: 0.93 MB (100%)
#> Error: Download does not have MIME type 'application/zip'.
#> Instead it's 'application/x-zip-compressed'.
Created on 2019-05-31 by the reprex package (v0.3.0)
I find the forced interactivity to be annoying most of the time. I understand why it's there, but can it be optional? Can it take an interactive argument to turn this off?
Why is the function called use_course() if I'm using it for something that has nothing to do with courses?
All I'm proposing would be to expose use_zip() as a more general-purpose function (with a fix for (1)), and then use_course() could continue to work as it currently does.
Is this true? What you like about use_course() and want to extract into use_zip() is a nice download function that:
Yes. And returns the fs_path to the resulting directory.
So instead of:
```{r}
src <- "https://www.fueleconomy.gov/feg/epadata/16data.zip"
download.file(src, destfile = "fueleconomy.zip")
unzip("fueleconomy.zip", exdir = "fueleconomy/")
lcl <- fs::path("fueleconomy/")
We'd just have:
```{r}
src <- "https://www.fueleconomy.gov/feg/epadata/16data.zip"
lcl <- usethis::use_zip(src)
OK see what you think of use_zip(). I have also been using use_course() just to get sane ZIP download + unpack behaviour, so I see your point.
Amazing!
The docs say: "doesn't insist on interactive confirmation.", but tidy_unzip() still wants to confirm the deletion of the ZIP file.
And thank you!
still wants to confirm the deletion of the ZIP file.
Yeah I was referring to interaction around destdir. What are your thoughts around deleting the ZIP file? I can't very well delete by default, but deleting is so nice. I think I'm OK with being asked this in an interactive setting.
Could there be a delete_zip argument that defaults to "ask" but will be quiet if it's set to TRUE or FALSE?
OK now you can do use_zip("r-lib/rematch2", cleanup = TRUE).
Thanks @jennybc !
Most helpful comment
OK now you can do
use_zip("r-lib/rematch2", cleanup = TRUE).