Skip to contents

Add text to a prompt by adding a prompt_wrap() which will append the text to the before or after the current prompt text.

Usage

add_text(prompt, text, position = c("after", "before"), sep = "\n\n")

Arguments

prompt

A single string or a tidyprompt() object

text

Text to be added to the current prompt text

position

Where to add the text; either "after" or "before".

sep

Separator to be used between the current prompt text and the text to be added

Value

A tidyprompt() with an added prompt_wrap() which will append the text to the end of the current prompt text

Examples

prompt <- "Hi there!" |>
  add_text("How is your day?")
prompt
#> <tidyprompt>
#> The base prompt is modified by a prompt wrap, resulting in:
#> > Hi there!
#> > 
#> > How is your day? 
#> Use '<tidyprompt>$prompt_wraps' to show the prompt wraps.
#> Use '<tidyprompt>$base_prompt' to show the base prompt text.
#> Use '<tidyprompt> |> construct_prompt_text()' to get the full prompt text.
#> 
prompt |>
  construct_prompt_text()
#> [1] "Hi there!\n\nHow is your day?"