-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FR: rextendr::use_crate()? #360
Comments
Yes definitely! You should definitely do this. We do not need to have all the arguments to the CLI either. Just the most common ones. If you need things like optional or nightly etc then you probably wont need an R package to help! Here's some start code we can use: compact <- function(.x) Filter(length, .x)
use_crate <- function(crate, features = NULL, git = NULL, path = ".") {
# TODO check arguments and that they are the right type and length
# consider adding standalone type checks
# get source directory
src_dir <- rprojroot::find_package_root_file(path, "src/rust")
# craft additional args
cargo_add_opts <- compact(list(
"--features" = features,
"--git" = git
))
# craft the additional arguments
adtl_args <- unname(unlist(Map(
function(.x, .nm) {
paste(.nm, paste0(.x, collapse = " "))
},
cargo_add_opts,
names(cargo_add_opts)
)))
# run the commmand
processx::run(
"cargo",
c("add", crate, adtl_args),
echo_cmd = TRUE,
wd = src_dir
)
} |
Thanks, @JosiahParry! I'll try to get a PR together this evening. But also, what about adding an |
my preference would be to use |
@kbvernon , did your PR resolve this issue or are you planning on adding more features? |
Ah, yeah, this issue is resolved with #361. Sorry, I forgot to close it! |
Similar to
usethis::use_package()
but for adding dependencies to Cargo.toml.Happy to contribute a PR for this if you all think it is worthwhile.
The text was updated successfully, but these errors were encountered: