File: cli-config.Rd

package info (click to toggle)
r-cran-cli 3.6.5-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,300 kB
  • sloc: ansic: 16,412; cpp: 37; sh: 13; makefile: 2
file content (596 lines) | stat: -rw-r--r-- 18,088 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/docs.R
\name{cli-config}
\alias{cli-config}
\title{cli environment variables and options}
\description{
cli environment variables and options
}
\section{User facing configuration}{


These are environment variables and options that users may set, to modify
the behavior of cli.
\subsection{Hyperlinks}{

cli uses ANSI escape sequences to create hyperlinks.
Specifically, cli creates \href{https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda}{OSC 8 hyperlinks} that have this syntax:

\if{html}{\out{<div class="sourceCode">}}\preformatted{OSC 8 ; \{OPTIONAL PARAMS \} ; \{URI\} ST \{LINK TEXT\} OSC 8 ; ; ST
}\if{html}{\out{</div>}}

Under the hood, \code{\link[=style_hyperlink]{style_hyperlink()}} is the helper that forms these links, but it is more common to request them indirectly via inline markup (documented in \code{help("links")}).
\subsection{\code{R_CLI_HYPERLINK_MODE}}{

Set to \code{posix} to force generating POSIX compatible ANSI hyperlinks.
This is about the specific operating system command (OSC) and string terminator (ST) used in hyperlinks.

If not set, then RStudio compatible links are generated. This is a
temporary crutch until RStudio handles POSIX hyperlinks correctly, and
after that it will be removed.
}

\subsection{\code{cli.hyperlink} option and \code{R_CLI_HYPERLINKS} env var}{

Set this option or env var to \code{true}, \code{TRUE} or \code{True} to tell cli that the terminal supports ANSI hyperlinks.
Leave this configuration unset (or set to anything else) when there is no hyperlink support.
Specifically, this configuration indicates the support for URL and file hyperlinks, requested via markup like \verb{\{.href url\}} or \verb{\{.file path/file\}}.
(Below we describe the configuration that indicates support for even more specialized types of hyperlinks.)

The option \code{cli.hyperlink} takes precedence over the \code{R_CLI_HYPERLINKS} env var.
}

\subsection{\verb{cli.hyperlink_*} options and \verb{R_CLI_HYPERLINK_*} env vars}{

cli supports a few special types of hyperlink that go beyond pointing to, e.g., a webpage or a file.
These specialized hyperlinks cause R-specific actions to happen, such as executing a bit of R code or opening specific documentation.

Set the relevant option or env var to \code{true}, \code{TRUE}, or \code{True} to tell cli that the terminal is capable of implementing these specialized behaviours.
Leave this configuration unset (or set to anything else) when there is no support for a specific type of hyperlink.\tabular{llll}{
   Action \tab Example inline markup \tab Option \tab Env var \cr
   Run R code \tab \verb{\{.run testthat::snapshot_review()\}} \tab \code{cli.hyperlink_run} \tab \code{R_CLI_HYPERLINK_RUN} \cr
   Open a help topic \tab \verb{\{.fun stats::lm\}} \verb{\{.topic tibble::tibble_options\}} \verb{\{.help [\{.fun lm\}](stats::lm)\}} \tab \code{cli.hyperlink_help} \tab \code{R_CLI_HYPERLINK_HELP} \cr
   Open a vignette \tab \verb{\{.vignette tibble::types\}} \tab \code{cli.hyperlink_vignette} \tab \code{R_CLI_HYPERLINK_VIGNETTE} \cr
}


In all cases, the option takes priority over the corresponding env var.
}

\subsection{\verb{cli.hyperlink_*_url_format} options and \verb{R_CLI_HYPERLINK_*_URL_FORMAT} env vars}{

Recall the overall structure of cli's hyperlinks:

\if{html}{\out{<div class="sourceCode">}}\preformatted{OSC 8 ; \{OPTIONAL PARAMS \} ; \{URI\} ST \{LINK TEXT\} OSC 8 ; ; ST
}\if{html}{\out{</div>}}

The \code{URI} part has a default format for each type of hyperlink, but it is possible to provide a custom format via an option or an env var.
If defined, the option takes priority over the env var.\tabular{llll}{
   Action \tab Default URI format \tab Customize via option \tab Customize via env var \cr
   Open a file \tab (see below) \tab \code{cli.hyperlink_file_url_format} \tab \code{R_CLI_HYPERLINK_FILE_URL_FORMAT} \cr
   Run R code \tab \code{x-r-run:{code}} \tab \code{cli.hyperlink_run_url_format} \tab \code{R_CLI_HYPERLINK_RUN_URL_FORMAT} \cr
   Open a help topic \tab \code{x-r-help:{topic}} \tab \code{cli.hyperlink_help_url_format} \tab \code{R_CLI_HYPERLINK_HELP_URL_FORMAT} \cr
   Open a vignette \tab \code{x-r-vignette:{vignette}} \tab \code{cli.hyperlink_vignette_url_format} \tab \code{R_CLI_HYPERLINK_VIGNETTE_URL_FORMAT} \cr
}


A format must be a glue-like template with the relevant placeholder in curly braces (\code{code}, \code{topic} or \code{vignette}).

Here's an example of a custom URI format for runnable code, which is useful in an integrated Positron terminal:

\if{html}{\out{<div class="sourceCode">}}\preformatted{positron://positron.positron-r/cli?command=x-r-run:\{code\}
}\if{html}{\out{</div>}}

(For backwards compatibility with older versions of RStudio, in some contexts, a legacy format is used, e.g. \code{ide:run:{code}}.)

The default handling for file hyperlinks is geared towards the expectations of RStudio and can't really be expressed as a URI format, but it's approximately \verb{file://\{path\}}, plus possibly passing \code{line} and \code{col} (yes, it really is \code{col}, not \code{column}) in the \verb{OPTIONAL PARAMS} part of the OSC 8 hyperlink.

A custom format can be provided for file hyperlinks and the relevant placeholders are \code{path}, \code{line}, and \code{column}.
Examples of custom file hyperlink formats:

\if{html}{\out{<div class="sourceCode">}}\preformatted{positron://file\{path\}:\{line\}:\{column\}
vscode://file\{path\}:\{line\}:\{column\}
txmt://open?url=file://\{path\}&line=\{line\}&column=\{column\}
}\if{html}{\out{</div>}}

It's OK if the format includes only \code{path}.
}

}

\subsection{User facing environment variables}{
\subsection{\code{NO_COLOR}}{

Set to a nonempty value to turn off ANSI colors.
See \code{\link[=num_ansi_colors]{num_ansi_colors()}}.
}

\subsection{\code{ESS_BACKGROUND_MODE}}{

Set this environment variable to \code{light} or \code{dark} to indicate dark mode
in Emacs. Once https://github.com/emacs-ess/ESS/pull/1178 is merged, ESS
will set this automatically.
}

\subsection{\code{R_CLI_DYNAMIC}}{

Set to \code{true}, \code{TRUE} or \code{True} to assume a dynamic terminal, that supports \verb{\\r}.
Set to anything else to assume a non-dynamic terminal.
See \code{\link[=is_dynamic_tty]{is_dynamic_tty()}}.
}

\subsection{\code{R_CLI_NUM_COLORS}}{

Set to a positive integer to assume a given number of colors.
See \code{\link[=num_ansi_colors]{num_ansi_colors()}}.
}

}

\subsection{User facing options}{
\subsection{\code{cli.ansi}}{

Set to \code{true}, \code{TRUE} or \code{True} to assume a terminal that supports ANSI
control sequences.
Set to anything else to assume a non-ANSI terminal.
See \code{\link[=is_ansi_tty]{is_ansi_tty()}}.
}

\subsection{\code{cli.condition_unicode_bullets}}{

\code{TRUE} or \code{FALSE} to force turn on or off the Unicode symbols when printing
conditions. E.g. in \code{format_error()}, \code{format_warning()}, \code{format_message()} and
also in \code{cli_abort()}, \code{cli_warn()} and \code{cli_inform()}.
}

\subsection{\code{cli.condition_width}}{

Integer scalar (or \code{Inf}) to set the console width when cli is formatting
errors, warnings or messages in \code{format_error()}, \code{format_warning()} and
\code{format_message()}. When formatting conditions this option takes precedence
over \code{cli.width}.
}

\subsection{\code{cli.default_handler}}{

General handler function for all cli conditions.
See \url{https://cli.r-lib.org/articles/semantic-cli.html#cli-messages-1}
}

\subsection{\code{cli.default_num_colors}}{

Default number of ANSI colors. This value is used if the number of colors
is not already set by
\itemize{
\item the \code{cli.num_colors} option,
\item the \code{R_CLI_NUM_COLORS} environment variable,
\item the \code{crayon.enabled} and \code{crayon.colors} options,
\item the \code{NO_COLOR} environment variable,
\item the \code{knitr.in.progress} option,
\item a \code{sink()} call for the stream.
}

You can also use this option if color support is detected correctly, but
you want to adjust the number of colors. E.g.
\itemize{
\item if \code{crayon.enabled} is \code{TRUE}, but \code{crayon.colors} is not,
\item in Emacs on Windows,
\item in terminals.
}

See \code{\link[=num_ansi_colors]{num_ansi_colors()}}. See also the \code{cli.num_colors} option.
}

\subsection{\code{cli.dynamic}}{

Set to \code{TRUE} to assume a dynamic terminal, that supports \verb{\\r}.
Set to anything else to assume a non-dynamic terminal.
See \code{\link[=is_dynamic_tty]{is_dynamic_tty()}}.
}

\subsection{\code{cli.hide_cursor}}{

Whether the cli status bar should try to hide the cursor on terminals.
Set the \code{FALSE} if the hidden cursor causes issues.
}

\subsection{\code{cli.ignore_unknown_rstudio_theme}}{

Set to \code{TRUE} to omit a warning for an unknown RStudio theme in
\code{code_highlight()}.
}

\subsection{\code{cli.num_colors}}{

Number of ANSI colors. See \code{\link[=num_ansi_colors]{num_ansi_colors()}}. See also the
\code{cli.default_num_colors} option.
}

\subsection{\code{cli.message_class}}{

Character vector of classes to add to cli's conditions.
}

\subsection{\code{cli.progress_bar_style}}{

Progress bar style.
See \code{\link[=cli_progress_styles]{cli_progress_styles()}}.
}

\subsection{\code{cli.progress_bar_style_ascii}}{

Progress bar style on ASCII consoles.
See \code{\link[=cli_progress_styles]{cli_progress_styles()}}.
}

\subsection{\code{cli.progress_bar_style_unicode}}{

Progress bar style on Unicode (UTF-8) consoles;
See \code{\link[=cli_progress_styles]{cli_progress_styles()}}.
}

\subsection{\code{cli.progress_clear}}{

Whether to clear terminated progress bar from the screen on dynamic terminals.
See \code{\link[=cli_progress_bar]{cli_progress_bar()}}.
}

\subsection{\code{cli.progress_demo_live}}{

Whether \code{cli_progress_demo()} should show a live demo, or just record the
progress bar frames.
}

\subsection{\code{cli.progress_format_download}}{

Default format string for \code{download} progress bars.
}

\subsection{\code{cli.progress_format_download_nototal}}{

Default format string for \code{download} progress bars with unknown totals.
}

\subsection{\code{cli.progress_format_iterator}}{

Default format string for \code{iterator} progress bars.
}

\subsection{\code{cli.progress_format_iterator_nototal}}{

Default format string for \code{iterator} progress bars with unknown total number
of progress units.
}

\subsection{\code{cli.progress_format_tasks}}{

Default format string for \code{tasks} progress bars.
}

\subsection{\code{cli.progress_format_tasks_nototal}}{

Default format string for \code{tasks} progress bars with unknown totals.
}

\subsection{\code{cli.progress_handlers}}{

Progress handlers to try.
See \code{\link[=cli_progress_builtin_handlers]{cli_progress_builtin_handlers()}}.
}

\subsection{\code{cli.progress_handlers_force}}{

Progress handlers that will always be used, even if another handler
was already selected.
See \code{\link[=cli_progress_builtin_handlers]{cli_progress_builtin_handlers()}}.
}

\subsection{\code{cli.progress_handlers_only}}{

Progress handlers to force, ignoring handlers set in
\code{cli.progress_handlers} and \code{cli.progress_handlers_force}.
See \code{\link[=cli_progress_builtin_handlers]{cli_progress_builtin_handlers()}}.
}

\subsection{\code{cli.progress_say_args}}{

Command line arguments for the \code{say} progress handlers.
See \code{\link[=cli_progress_builtin_handlers]{cli_progress_builtin_handlers()}}.
}

\subsection{\code{cli.progress_say_command}}{

External command to use in the \code{say} progress handler.
See \code{\link[=cli_progress_builtin_handlers]{cli_progress_builtin_handlers()}}.
}

\subsection{\code{cli.progress_say_frequency}}{

Minimum delay between \code{say} calls in the \code{say} progress handler.
\code{say} ignores very frequent updates, to keep the speech comprehensible.
See \code{\link[=cli_progress_builtin_handlers]{cli_progress_builtin_handlers()}}.
}

\subsection{\code{cli.progress_show_after}}{

Delay before showing a progress bar, in seconds.
Progress bars that finish before this delay are not shown at all.
cli also shows progress bars that have more than 50\% to go after half of
this delay has passed.
}

\subsection{\code{cli.spinner}}{

Default spinner to use, see \code{\link[=get_spinner]{get_spinner()}}.
}

\subsection{\code{cli.spinner_ascii}}{

Default spinner to use on ASCII terminals, see \code{\link[=get_spinner]{get_spinner()}}.
}

\subsection{\code{cli.spinner_unicode}}{

Default spinner to use on Unicode terminals, see \code{\link[=get_spinner]{get_spinner()}}.
}

\subsection{\code{cli.theme}}{

Default cli theme, in addition to the built-in theme.
This option in intended for the package developers.
See \link{themes} and \code{\link[=start_app]{start_app()}}.
}

\subsection{\code{cli.theme_dark}}{

Whether cli should assume a dark theme for the builtin theme.
See \code{\link[=builtin_theme]{builtin_theme()}}.
}

\subsection{\code{cli.unicode}}{

Whether to assume a Unicode terminal.
If not set, then it is auto-detected.
See \code{\link[=is_utf8_output]{is_utf8_output()}}.
}

\subsection{\code{cli.user_theme}}{

cli user theme.
This option is intended for end users.
See \link{themes}.
}

\subsection{\code{cli.warn_inline_newlines}}{

Whether to emit a warning when cli replaces newline characters with
spaces within a \code{{.class }} inline style.
Defaults to \code{FALSE}.
}

\subsection{\code{cli.width}}{

Terminal width to assume.
If not set, then it is auto-detected.
See \code{\link[=console_width]{console_width()}}.
}

\subsection{\code{rlib_interactive}}{

Whether to assume an interactive R session.
If not set, then it is auto-detected.
}

\subsection{\code{width}}{

Terminal width.
This is used on some platforms, if \code{cli.width} is not set.
}

}
}

\section{Internal configuration}{


These environment variables and options are for cli developers. Users
should not rely on them as they may change between cli releases.
\subsection{Internal environment variables}{
\subsection{\code{ASCIICAST}}{

Used to detect an asciicast sub-process in RStudio.
}

\subsection{\code{ANSICON}}{

Used to detect ANSICON when detecting the number of ANSI colors.
}

\subsection{\code{CI}}{

Used to detect if the code is running on a CI.
If yes, we avoid ANSI hyperlinks.
}

\subsection{\code{CLI_DEBUG_BAD_END}}{

Whether to warn about \code{cli_end()} calls when there is no container to close.
}

\subsection{\code{CLI_NO_BUILTIN_THEME}}{

Set it to \code{true} to omit the builtin theme.
}

\subsection{\code{CLI_SPEED_TIME}}{

Can be used to speed up cli's timer.
It is a factor, e.g. setting it to 2 makes cli's time go twice as fast.
}

\subsection{\code{CLI_TICK_TIME}}{

How often the cli timer should alert, in milliseconds.
}

\subsection{\code{CMDER_ROOT}}{

Used to detect cmder when detecting the number of ANSI colors.
}

\subsection{\code{COLORTERM}}{

Used when detecting ANSI color support.
}

\subsection{\code{ConEmuANSI}}{

Used to detect ConEmu when detecting the number of ANSI colors.
}

\subsection{\code{EMACS}}{

Used to detect Emacs.
}

\subsection{\code{INSIDE_EMACS}}{

Used to detect Emacs.
}

\subsection{\code{NOT_CRAN}}{

Set to \code{true} to run tests / examples / checks, that do not run on CRAN.
}

\subsection{\verb{_R_CHECK_PACKAGE_NAME_}}{

Used to detect \verb{R CMD check}.
}

\subsection{\code{R_BROWSER}}{

Used to detect the RStudio build pane.
}

\subsection{\code{R_GUI_APP_VERSION}}{

Used to detect R.app on macOS, to decide if the console has ANSI control
sequences.
}

\subsection{\code{R_PACKAGE_DIR}}{

Used to detect if the code is running under \verb{R CMD INSTALL}.
}

\subsection{\code{R_PDFVIEWER}}{

Used to detect the RStudio build pane.
}

\subsection{\code{R_PROGRESS_NO_EXAMPLES}}{

Set to \code{true} to avoid running examples, outside of \verb{R CMD check}.
}

\subsection{\code{RSTUDIO}}{

Used to detect RStudio, in various functions.
}

\subsection{\code{RSTUDIO_CONSOLE_COLOR}}{

Used to detect the number of colors in RStudio.
See \code{\link[=num_ansi_colors]{num_ansi_colors()}}.
}

\subsection{\code{RSTUDIO_CONSOLE_WIDTH}}{

Used to auto-detect console width in RStudio.
}

\subsection{\code{RSTUDIO_TERM}}{

Used to detect the RStudio build pane.
}

\subsection{\code{TEAMCITY_VERSION}}{

Used to detect the TeamCity CI, to turn off ANSI hyperlinks.
}

\subsection{\code{TERM}}{

Used to detect if the console has ANSI control sequences, in a terminal.
}

\subsection{\code{TERM_PROGRAM}}{

Used to detect iTerm for the dark theme detection and the ANSI hyperlink
support detection.
}

\subsection{\code{TERM_PROGRAM_VERSION}}{

Used to detect a suitable iTerm version for ANSI hyperlink support.
}

\subsection{\code{TESTTHAT}}{

Used to detect running in testthat tests.
}

\subsection{\code{VTE_VERSION}}{

Used to detect a suitable VTE version for ANSI hyperlinks.
}

}

\subsection{Internal options}{
\subsection{\code{cli__pb}}{

This option is set to the progress bar that is being updated, when
interpolating the format string.
}

\subsection{\code{cli.record}}{

Internal option to mark the state that cli is recording messages.
}

\subsection{\code{crayon.colors}}{

Deprecated option for the number of ANSI colors, that is still supported
by cli, when the new options are not set.
See \code{\link[=num_ansi_colors]{num_ansi_colors()}}.
}

\subsection{\code{crayon.enabled}}{

Deprecated option to turn ANSI colors on/off.
This is still supported by cli when the new options are not set.
See \code{\link[=num_ansi_colors]{num_ansi_colors()}}.
}

\subsection{\code{crayon.hyperlink}}{

Whether to assume ANSI hyperlink support.
See \code{\link[=ansi_has_hyperlink_support]{ansi_has_hyperlink_support()}}.
}

\subsection{\code{knitr.in.progress}}{

Used to detect knitr when detecting interactive sessions and ANSI color
support.
}

\subsection{\code{rstudio.notebook.executing}}{

Used to detect knitr when detecting interactive sessions.
}

}
}