From 1c08c3b025e04745e9cc2f4150a8ef776fa340d9 Mon Sep 17 00:00:00 2001 From: hrbrmstr Date: Thu, 18 Jun 2020 06:50:52 -0400 Subject: [PATCH] addin --- NAMESPACE | 1 + R/addin.R | 21 +++++++++++++++++++-- README.Rmd | 4 +++- README.md | 24 +++++++++++++++++------- inst/rstudio/addins.dcf | 5 +++++ man/open_bitbar_dir.Rd | 11 +++++++++++ 6 files changed, 56 insertions(+), 10 deletions(-) create mode 100644 man/open_bitbar_dir.Rd diff --git a/NAMESPACE b/NAMESPACE index 90b9fc4..9069847 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -6,6 +6,7 @@ export(add_separator) export(b64_image) export(bitbar_plugins_dir) export(new_bitbar_script) +export(open_bitbar_dir) export(r_logo_small) import(httr) import(miniUI) diff --git a/R/addin.R b/R/addin.R index edc791e..1c8af04 100644 --- a/R/addin.R +++ b/R/addin.R @@ -50,7 +50,19 @@ create_new_bitbar_script <- function() { about_url = input$about_url ) - stopApp(returnValue) + stopApp( + list( + save_as = input$save_as, + title = input$title, + version = input$version, + author = input$author, + github_user = input$github_user, + description = input$description, + dependencies = input$dependencies, + image_url = input$image_url, + about_url = input$about_url + ) + ) }) @@ -62,4 +74,9 @@ create_new_bitbar_script <- function() { } - +#' Open BitBar Plugins Directory in the Finder +#' +#' @export +open_bitbar_dir <- function() { + system(sprintf("open %s", shQuote(bitbar_plugins_dir()))) +} \ No newline at end of file diff --git a/README.Rmd b/README.Rmd index 9a482b8..0661708 100644 --- a/README.Rmd +++ b/README.Rmd @@ -37,6 +37,8 @@ The following functions are implemented: hrbrpkghelpr::describe_ingredients() ``` +There are also two RStudio Addins, one with a GUI for entering in the script metadata & starting a new BitBar {bitbar} script and one for opening up the BitBar plugins directory in the Finder. + ## Installation ```{r install-ex, results='asis', echo=FALSE, cache=FALSE} @@ -59,7 +61,7 @@ This will open up a `my-awesome-bitbar-script.R` in RStudio (if available) or wh new_bitbar_script( save_as = file.path(bitbar_plugins_dir(), "my-awesome-bitbar-script.R"), title = ":blue_heart:", - description = "Example BitBar Script") + description = "Example BitBar Script" ) ``` diff --git a/README.md b/README.md index d2627db..1e215dd 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ by](https://img.shields.io/badge/Keybase-Verified-brightgreen.svg)](https://keyb [![Linux build Status](https://travis-ci.org/hrbrmstr/bitbar.svg?branch=master)](https://travis-ci.org/hrbrmstr/bitbar) ![Minimal R -Version](https://img.shields.io/badge/R%3E%3D-3.5.0-blue.svg) +Version](https://img.shields.io/badge/R%3E%3D-3.6.0-blue.svg) ![License](https://img.shields.io/badge/License-MIT-blue.svg) # bitbar @@ -36,18 +36,26 @@ it the hard way. Open the application and choose the directory you want to be your plugins directory. This is where your menubar scripts will go. (I use -`~/Library/Application Support/BitBar/Plugins` but you can pick any -directory; just make sure it isn’t one with a gazillion files as that -impacts BitBar’s performance). +`~/Library/BitBar/Plugins` but you can pick any directory; just make +sure it isn’t one with a gazillion files as that impacts BitBar’s +performance). ## What’s Inside The Tin The following functions are implemented: - `add_entry`: Add an entry to the menu + - `b64_image`: Return a base64 encoded string of an image (local + filesystem or URL) - `bitbar_plugins_dir`: BitBar plugins directory - `new_bitbar_script`: Helper to get started with a new BitBar bitbar script + - `open_bitbar_dir`: Open BitBar Plugins Directory in the Finder + - `r_logo_small`: Images that come with the package + +There are also two RStudio Addins, one with a GUI for entering in the +script metadata & starting a new BitBar {bitbar} script and one for +opening up the BitBar plugins directory in the Finder. ## Installation @@ -59,6 +67,8 @@ remotes::install_git("https://git.sr.ht/~hrbrmstr/bitbar") remotes::install_gitlab("hrbrmstr/bitbar") # or remotes::install_bitbucket("hrbrmstr/bitbar") +# or +remotes::install_github("hrbrmstr/bitbar") ``` NOTE: To use the ‘remotes’ install options you will need to have the @@ -81,7 +91,7 @@ available) or whatever editor `file.edit()` is configured to use. new_bitbar_script( save_as = file.path(bitbar_plugins_dir(), "my-awesome-bitbar-script.R"), title = ":blue_heart:", - description = "Example BitBar Script") + description = "Example BitBar Script" ) ``` @@ -89,8 +99,8 @@ new_bitbar_script( | Lang | \# Files | (%) | LoC | (%) | Blank lines | (%) | \# Lines | (%) | | :--- | -------: | ---: | --: | ---: | ----------: | ---: | -------: | ---: | -| R | 7 | 0.88 | 96 | 0.88 | 29 | 0.57 | 68 | 0.63 | -| Rmd | 1 | 0.12 | 13 | 0.12 | 22 | 0.43 | 40 | 0.37 | +| R | 10 | 0.91 | 191 | 0.94 | 51 | 0.69 | 79 | 0.66 | +| Rmd | 1 | 0.09 | 13 | 0.06 | 23 | 0.31 | 41 | 0.34 | ## Code of Conduct diff --git a/inst/rstudio/addins.dcf b/inst/rstudio/addins.dcf index b2138ca..8970309 100644 --- a/inst/rstudio/addins.dcf +++ b/inst/rstudio/addins.dcf @@ -2,3 +2,8 @@ Name: Create a new {bitbar} script Description: Create a new {bitbar} script Binding: create_new_bitbar_script Interactive: true + +Name: Open {bitbar} Plugins Directory +Description: Open {bitbar} Plugins Directory in the Finder +Binding: open_bitbar_dir +Interactive: false diff --git a/man/open_bitbar_dir.Rd b/man/open_bitbar_dir.Rd new file mode 100644 index 0000000..455e5de --- /dev/null +++ b/man/open_bitbar_dir.Rd @@ -0,0 +1,11 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/addin.R +\name{open_bitbar_dir} +\alias{open_bitbar_dir} +\title{Open BitBar Plugins Directory in the Finder} +\usage{ +open_bitbar_dir() +} +\description{ +Open BitBar Plugins Directory in the Finder +}