year <- sub("-.*", "", meta$Date)
if (is.null(year) || identical(year, "") || isTRUE(length(year) == 0))
  year <- format(Sys.Date(), "%Y")

ndots <- length(gregexpr(".", meta$Version, fixed = TRUE)[[1]])
if (ndots == 3) {
  cite_url <- "https://github.com/prioritizr/oppr"
} else {
  cite_url <- "https://CRAN.R-project.org/package=oppr"
}

citHeader("To cite the oppr package in publications, please use:")

citEntry(
  entry = "Article",
  author = personList(
    person(c("Jeffrey", "O"), "Hanson"),
    person(c("Richard"), "Schuster"),
    person(c("Matthew"), "Strimas-Mackey"),
    person(c("Joseph"), "Bennett")),
  title = "Optimality in prioritizing conservation projects",
  year = 2019,
  journal = "Methods in Ecology and Evolution",
  volume = 10,
  number = 10,
  pages = "1655--1663",
  doi = "10.1111/2041-210X.13264",
  textVersion = paste0("Hanson JO, Schuster R, Strimas-Mackey M & Bennett JR (2019) Optimality in prioritizing conservation projects. Methods in Ecology & Evolution, 10: 1655--1663.")
)

citEntry(
  entry = "Manual",
  author = personList(
    person(c("Jeffrey", "O"), "Hanson"),
    person(c("Richard"), "Schuster"),
    person(c("Matthew"), "Strimas-Mackey"),
    person(c("Joseph"), "Bennett")),
  title = "oppr: Optimal Project Prioritization",
  year = year,
  note = paste("R package version", meta$Version),
  url = cite_url,
  textVersion = paste0(
     "Hanson JO, Schuster R, Strimas-Mackey M, Bennett J (", year,
     ") oppr: Optimal Project Prioritization ",
     "R package version ", meta$Version, ". ",
     cite_url
  )
)
