Created
May 12, 2025 03:08
-
-
Save jimjam-slam/b3214de5c40f9807520120f9bac30e1b to your computer and use it in GitHub Desktop.
#Raycast script command to search installed R package documentation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env Rscript | |
# Raycast Script Command: Search R Help | |
# | |
# @raycast.schemaVersion 1 | |
# @raycast.title Search R Help | |
# @raycast.description Search installed R packages for documentation | |
# @raycast.mode silent | |
# @raycast.icon 📖 | |
# @raycast.packageName Raycast Scripts | |
# @raycast.author James Goldie | |
# @raycast.authorURL https://jamesgoldie.dev | |
# @raycast.argument1 { "type": "text", "placeholder": "function", "percentEncoded": false } | |
# @raycast.argument2 { "type": "text", "placeholder": "package", "percentEncoded": false, "optional": true } | |
args = commandArgs(trailingOnly = TRUE) | |
stopifnot( | |
"This script takes either one or two arguments." = length(args) %in% 1:2, | |
"The argument should be a string." = is(args, "character")) | |
topic <- args[1] | |
pkg <- ifelse(length(args) < 2, NULL, args[2]) | |
help((topic), package = (pkg), help_type = "html") | |
cat("Searching R help for:", topic, | |
ifelse(is.null(pkg), "", paste("in", pkg)), "\n") | |
Sys.sleep(1) # just long enough to ensure the page loads |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment