Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

* `pr_resume()` (without a specific `branch`) and `pr_fetch()` (without a specific `number`) no longer error when a branch name contains curly braces (#2107, @jonthegeek).

* Adds `open` argument to `use_c()`, `use_rcpp()`, `use_rcpp_armadillo()`, `use_rcpp_eingen()`, `use_makevars()` and `use_cpp11()` (#2207, @brunomartins-rdev).*

# usethis 3.2.1

* `create_quarto_project()` exits early if the Quarto CLI does not appear to be
Expand Down
6 changes: 4 additions & 2 deletions R/cpp11.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
#' * Adds cpp11 to `DESCRIPTION`
#' * Creates `src/code.cpp`, an initial placeholder `.cpp` file
#'
#' @param open Whether to open the file for interactive editing.
#'
#' @export
use_cpp11 <- function() {
use_cpp11 <- function(open = rlang::is_interactive()) {
check_is_package("use_cpp11()")
check_installed("cpp11")
check_uses_roxygen("use_cpp11()")
Expand All @@ -20,7 +22,7 @@ use_cpp11 <- function() {
use_template(
"code-cpp11.cpp",
path("src", "code.cpp"),
open = is_interactive()
open = open
)

check_cpp_register_deps()
Expand Down
22 changes: 11 additions & 11 deletions R/rcpp.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#'
#' @inheritParams use_r
#' @export
use_rcpp <- function(name = NULL) {
use_rcpp <- function(name = NULL, open = rlang::is_interactive()) {
check_is_package("use_rcpp()")
check_uses_roxygen("use_rcpp()")

Expand All @@ -19,15 +19,15 @@ use_rcpp <- function(name = NULL) {
use_src()
path <- path("src", compute_name(name, "cpp"))
use_template("code.cpp", path)
edit_file(proj_path(path))
edit_file(proj_path(path), open = open)

invisible()
}

#' @rdname use_rcpp
#' @export
use_rcpp_armadillo <- function(name = NULL) {
use_rcpp(name)
use_rcpp_armadillo <- function(name = NULL, open = rlang::is_interactive()) {
use_rcpp(name, open = open)

use_dependency("RcppArmadillo", "LinkingTo")

Expand All @@ -43,8 +43,8 @@ use_rcpp_armadillo <- function(name = NULL) {

#' @rdname use_rcpp
#' @export
use_rcpp_eigen <- function(name = NULL) {
use_rcpp(name)
use_rcpp_eigen <- function(name = NULL, open = rlang::is_interactive()) {
use_rcpp(name, open = open)

use_dependency("RcppEigen", "LinkingTo")

Expand All @@ -55,15 +55,15 @@ use_rcpp_eigen <- function(name = NULL) {

#' @rdname use_rcpp
#' @export
use_c <- function(name = NULL) {
use_c <- function(name = NULL, open = rlang::is_interactive()) {
check_is_package("use_c()")
check_uses_roxygen("use_c()")

use_src()

path <- path("src", compute_name(name, ext = "c"))
use_template("code.c", path)
edit_file(proj_path(path))
edit_file(proj_path(path), open = open)

invisible(TRUE)
}
Expand All @@ -79,7 +79,7 @@ use_src <- function() {
invisible()
}

use_makevars <- function(settings = NULL) {
use_makevars <- function(settings = NULL, open = rlang::is_interactive()) {
use_directory("src")

settings_list <- settings %||% list()
Expand Down Expand Up @@ -107,7 +107,7 @@ use_makevars <- function(settings = NULL) {
makevars_content,
language = ""
)
edit_file(makevars_path)
edit_file(makevars_win_path)
edit_file(makevars_path, open = open)
edit_file(makevars_win_path, open = open)
}
}
5 changes: 4 additions & 1 deletion man/use_cpp11.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions man/use_rcpp.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.