Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could you highlight the use of vec-last and vec-sep in docs? #619

Open
mkalamarz opened this issue Jul 11, 2023 · 4 comments
Open

Could you highlight the use of vec-last and vec-sep in docs? #619

mkalamarz opened this issue Jul 11, 2023 · 4 comments
Labels
documentation tidy-dev-day 🤓 Tidyverse Developer Day rstd.io/tidy-dev-day

Comments

@mkalamarz
Copy link

I feel like it took me way too long to stumble opon these two in cli_vec(). Shouldn't this be mentioned in here or there? I was fortunate to find this info by chance when looking at the truncation example on the inline markup article (which isn't mentioned in "Building a semantic CLI" one) and thinking "Maybe I should check this cli_vec() thingy?".

@gaborcsardi
Copy link
Member

That sounds like a good idea. Would you like to submit a PR? (No pressure and no need to worry about rebuilding the docs, which is a pain in the neck.)

@mkalamarz
Copy link
Author

mkalamarz commented Jul 12, 2023

@gaborcsardi I can't promise anything. But if I will find a moment, am I correct that there is no global setting for these two options of collapsing vectors?

@gaborcsardi
Copy link
Member

They are part of the theme, so the end user can change them with a custom theme, e.g.

options(cli.user_theme = list(body = list("vec-sep" = " + ", "vec-last" = " --- ")))
cli::cli_alert_info("These: {1:5}.")

#> ℹ These: 1 + 2 + 3 + 4 --- 5.

However, in practice I am not sure if this makes sense, because it will apply to all packages using cli (if attached to body). It does make sense in some restricted context.

@salim-b
Copy link
Contributor

salim-b commented Jan 30, 2024

Just an observation: cli_vec() is somewhat related to ansi_collapse():

x  <- cli::cli_vec(names(mtcars), list("vec-trunc" = 3))
x2 <- cli::ansi_collapse(names(mtcars), trunc = 3)

str(x)
#>  chr [1:11] "mpg" "cyl" "disp" "hp" "drat" "wt" "qsec" "vs" "am" "gear" ...
#>  - attr(*, "cli_style")=List of 1
#>   ..$ vec-trunc: num 3
str(x2)
#>  chr "mpg, cyl, disp, …, gear, and carb"

cli::cli_text("Column names: {x}.")
#> Column names: mpg, cyl, disp, …, gear, and carb.
cli::cli_text("Column names: {x2}.")
#> Column names: mpg, cyl, disp, …, gear, and carb.

Created on 2024-01-30 with reprex v2.1.0

ansi_collapse() is used by the internal cli:::inline_collapse() when a cli string is rendered.

@gaborcsardi gaborcsardi added the tidy-dev-day 🤓 Tidyverse Developer Day rstd.io/tidy-dev-day label Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation tidy-dev-day 🤓 Tidyverse Developer Day rstd.io/tidy-dev-day
Projects
None yet
Development

No branches or pull requests

3 participants