@@ -68,16 +68,16 @@ Rapp::install_pkg_cli_apps("Rapp")
6868
6969On macOS and Linux, make your script executable (` chmod +x flip-coin.R ` )
7070and run it directly. On Windows, or if you prefer, call the front end
71- explicitly: ` Rapp flip-coin.R --n 3 ` .
71+ explicitly with ` Rapp flip-coin.R --n 3 ` .
7272
7373Application options and arguments work like this:
7474
7575| Script declaration | CLI usage | Effect |
7676| --- | --- | --- |
77- | ` foo <- NULL ` | ` APP < FOO> ` | Positional argument with a default value |
77+ | ` foo <- NULL ` | ` APP [ FOO] ` | Optional positional argument |
7878| ` foo <- TRUE ` / ` foo <- FALSE ` | ` APP --foo ` / ` APP --no-foo ` | Boolean switch |
79- | ` foo <- 1 ` , ` foo <- 1.5 ` , ` foo <- "value "` | ` APP --foo VALUE ` | Single-value option |
80- | ` foo <- c() ` / ` foo <- list() ` | ` APP --foo value1 --foo value2 ` | Repeatable option that appends each value |
79+ | ` foo <- 1 ` , ` foo <- "default " ` | ` APP --foo VALUE ` | Single-value option |
80+ | ` foo <- c() ` / ` foo <- list() ` | ` APP --foo value1 --foo value2 ` | Repeatable option that appends each value ( ` c() ` keeps strings, ` list() ` parses YAML/JSON) |
8181
8282## Options
8383
@@ -94,7 +94,7 @@ becomes an option at the command line:
9494flip-coin --n 1
9595```
9696
97- Option values passed from the command line are parsed as yaml/json , and
97+ Option values passed from the command line are parsed as YAML/JSON , and
9898then coerced to the original R type. The following option value types
9999are supported: int, float, string, and bool. Values can be supplied
100100after the option, or as part of the option with ` = ` . The following two
@@ -134,16 +134,34 @@ Hash-pipe annotations are parsed as YAML values. Quote scalars such as
134134interpretation.
135135
136136Assigning ` c() ` or ` list() ` now declares a repeatable option. Each time
137- the option is supplied, its value is appended in order. For example:
137+ the option is supplied, its value is appended in order. Use ` c() ` when
138+ you want to keep the exact strings provided on the command line, and
139+ ` list() ` when you want Rapp to opportunistically parse values as
140+ YAML/JSON (so you can receive integers, booleans, lists, etc). For
141+ example, a repeatable filter option that keeps raw strings:
138142
139143``` r
144+ # | description: File name patterns to include (repeatable).
140145pattern <- c()
141146```
142147
143- becomes :
148+ can be invoked as :
144149
145150``` bash
146- ls-r --pattern alpha --pattern " .*\\ .txt$"
151+ list-files --pattern ' *.csv' --pattern sales-*
152+ ```
153+
154+ Or, to collect numeric limits and have them parsed back into integers:
155+
156+ ``` r
157+ # | description: Score thresholds (parsed as numbers, repeatable).
158+ threshold <- list ()
159+ ```
160+
161+ which lets callers supply structured values:
162+
163+ ``` bash
164+ report --threshold 5 --threshold ' [10, 20, 30]'
147165```
148166
149167## Positional arguments
@@ -357,7 +375,7 @@ like on other platforms:
357375flip-coin --n 3
358376```
359377
360- Because windows does not natively support shebangs, to invoke an Rapp
378+ Because Windows does not natively support shebangs, to invoke an Rapp
361379developed outside an R package, you'll need to invoke the ` Rapp `
362380front-end directly (after calling ` Rapp::install_pkg_cli_apps("Rapp") ` ):
363381
0 commit comments