Skip to content

Commit 355ef29

Browse files
committed
rig run
1 parent 3eab284 commit 355ef29

File tree

15 files changed

+761
-28
lines changed

15 files changed

+761
-28
lines changed

Cargo.lock

+48-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ semver = "1.0.4"
4040
serde = { version = "1.0", features = ["derive"] }
4141
serde_derive = "1.0"
4242
serde_json = "1.0"
43+
serde_yaml = "0.9"
4344
sha2 = "0.9.8"
4445
shellexpand = "2.1.0"
4546
simple-error = "0.2.3"

README.Rmd

+2
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,14 @@ Run `rig` to see all commands and examples.
190190

191191
```
192192
rig add -- install a new R version [alias: install]
193+
rig available -- List R versions available to install.
193194
rig default -- print or set default R version [alias: switch]
194195
rig library -- manage package libraries [alias: lib] (experimental)
195196
rig list -- list installed R versions [alias: ls]
196197
rig resolve -- resolve a symbolic R version
197198
rig rm -- remove R versions [aliases: del, delete, remove]
198199
rig rstudio -- start RStudio with the specified R version
200+
rig run -- Run R, an R script or an R project
199201
rig sysreqs -- manage R-related system libraries and tools (experimental) (macOS)
200202
rig system -- manage current installations
201203
```

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,14 @@ Run `rig` to see all commands and examples.
181181
### Command list:
182182

183183
rig add -- install a new R version [alias: install]
184+
rig available -- List R versions available to install.
184185
rig default -- print or set default R version [alias: switch]
185186
rig library -- manage package libraries [alias: lib] (experimental)
186187
rig list -- list installed R versions [alias: ls]
187188
rig resolve -- resolve a symbolic R version
188189
rig rm -- remove R versions [aliases: del, delete, remove]
189190
rig rstudio -- start RStudio with the specified R version
191+
rig run -- Run R, an R script or an R project
190192
rig sysreqs -- manage R-related system libraries and tools (experimental) (macOS)
191193
rig system -- manage current installations
192194

src/args.rs

+61-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@ pub fn rig_app() -> Command {
2424
let _arch_x86_64: &'static str = "x86_64";
2525
let _arch_arm64: &'static str = "arm64";
2626
let mut _default_arch: &'static str = "";
27+
let app_types = [
28+
"api",
29+
"shiny",
30+
"quarto-shiny",
31+
"rmd-shiny",
32+
"quarto-static",
33+
"rmd-static",
34+
"static"
35+
];
2736

2837
#[cfg(target_os = "macos")]
2938
{
@@ -560,28 +569,79 @@ pub fn rig_app() -> Command {
560569
.arg(
561570
Arg::new("r-version")
562571
.help("R version to use")
572+
.short('r')
563573
.long("r-version")
564574
.required(false)
565575
)
576+
.arg(
577+
Arg::new("app-type")
578+
.help("Explicitly specify app type to run")
579+
.short('t')
580+
.long("app-type")
581+
.required(false)
582+
.value_parser(app_types)
583+
.conflicts_with("eval")
584+
.conflicts_with("script")
585+
)
586+
.arg(
587+
Arg::new("dry-run")
588+
.help("Show the command, but do not run it")
589+
.long("dry-run")
590+
.required(false)
591+
.action(clap::ArgAction::SetTrue)
592+
)
593+
.arg(
594+
Arg::new("startup")
595+
.help("Print R startup message")
596+
.long("startup")
597+
.action(clap::ArgAction::SetTrue)
598+
.required(false)
599+
)
600+
.arg(
601+
Arg::new("no-startup")
602+
.help("Do not print R startup message")
603+
.long("no-startup")
604+
.action(clap::ArgAction::SetTrue)
605+
.required(false)
606+
.conflicts_with("startup")
607+
)
608+
.arg(
609+
Arg::new("echo")
610+
.help("Print input to R")
611+
.long("echo")
612+
.action(clap::ArgAction::SetTrue)
613+
.required(false)
614+
)
615+
.arg(
616+
Arg::new("no-echo")
617+
.help("Do not print input to R")
618+
.long("no-echo")
619+
.action(clap::ArgAction::SetTrue)
620+
.required(false)
621+
.conflicts_with("echo")
622+
)
566623
.arg(
567624
Arg::new("eval")
568625
.help("R expression to evaluate")
626+
.short('e')
569627
.long("eval")
570628
.num_args(1)
571629
.required(false)
572630
)
573631
.arg(
574632
Arg::new("script")
575633
.help("R script file to run")
634+
.short('f')
576635
.long("script")
577636
.num_args(1)
578637
.required(false)
638+
.conflicts_with("eval")
579639
)
580640
.arg(
581641
Arg::new("command")
582642
.help("R script or project to run, with parameters")
583643
.required(false)
584-
.action(clap::ArgAction::Append),
644+
.action(clap::ArgAction::Append)
585645
);
586646

587647
rig = rig.arg(

src/help-common.in

+22-1
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,25 @@ const HELP_RUN: &str = "
7272
\x1b[4m\x1b[1mDescription:\x1b[22m\x1b[24m
7373
Run R, an R script or an R project, using the selected R version.
7474
75-
TODO";
75+
All of these examples allow an `--r-version` argument, to use a specific
76+
R version.
77+
78+
Start R:
79+
rig run
80+
Run an R script:
81+
rig run -f <script-file>
82+
Evaluate an R expression:
83+
rig run -e <expression>
84+
Run a script from a package (from its `exec` directory):
85+
rig run <pkg>::<script>
86+
Run an R app:
87+
rig run <path-to-app>
88+
89+
Currently supported apps are:
90+
- Plumber APIs,
91+
- Shiny apps,
92+
- Quarto dcouments embedding Shiny apps,
93+
- Quarto documents,
94+
- Rmd documents,
95+
- Rmd documents embedding Shiny apps,
96+
- Static web sites.";

0 commit comments

Comments
 (0)