Skip to content

Instantly share code, notes, and snippets.

@arbelt
Created May 13, 2016 14:19
Show Gist options
  • Save arbelt/bbfa009f285a3a615bda00edeb0b4ed5 to your computer and use it in GitHub Desktop.
Save arbelt/bbfa009f285a3a615bda00edeb0b4ed5 to your computer and use it in GitHub Desktop.
#!/usr/bin/env Rscript
if (!require(pacman, quiet = TRUE)) install.packages("pacman")
pacman::p_load(docopt, dplyr, stringr, purrr)
"
Usage:
package.r [options] <pkgname>
package.r <pkgname> [-i <import>...]
Options:
-r --raw-data Use raw data
-i import..., --import import Specify imports (comma separated)
-v --verbose
" -> doc
opts <- docopt(doc)
if (opts$verbose) print(opts)
devtools::create(opts$pkgname)
if (isTRUE(opts$`raw-data`)) devtools::use_data_raw(opts$pkgname)
opts$import %>%
map(partial(devtools::use_package, pkg = opts$pkgname)) %>%
invisible
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment