Special-purpose function to download a folder of course materials. The only demand on the user is to confirm or specify where the new folder should be stored. Workflow:
User executes something like: use_course("bit.ly/xxx-yyy-zzz")
.
User is asked to notice and confirm the location of the new folder. Specify
destdir
to skip this.
User is asked if they'd like to delete the ZIP file.
If new folder contains an .Rproj
file, it is opened. Otherwise, the
folder is opened in the file manager, e.g. Finder or File Explorer.
use_course(url, destdir = NULL)
url | Link to a ZIP file containing the materials, possibly behind a
shortlink. Links of the form |
---|---|
destdir | The new folder is stored here. Defaults to user's Desktop. |
Path to the new directory holding the course materials, invisibly.
If url
has no "http" prefix, "https://" is prepended, allowing for even
less typing by the user. A url
of the form "repo/user"
, is assumed to
refer to a GitHub repository and is expanded appropriately, unless url
matches a URL shortener service, currently only "bit.ly"
or "rstd.io"
.
Most URL shorteners give HTTPS links and, anecdotally, we note this appears
to work with bit.ly links, even though they are
nominally HTTP.
Other download functions: use_course_details
# NOT RUN { ## bit.ly shortlink example ## should work with and without http prefix use_course("bit.ly/usethis-shortlink-example") use_course("http://bit.ly/usethis-shortlink-example") ## demo with a small CRAN package available in various places ## from CRAN use_course("https://cran.r-project.org/bin/windows/contrib/3.4/rematch2_2.0.1.zip") ## from GitHub, 3 ways use_course("r-lib/rematch2") use_course("https://github.com/r-lib/rematch2/archive/master.zip") use_course("https://api.github.com/repos/r-lib/rematch2/zipball/master") # }