stdio

Built-in standard input / output & utility functions

Example usage

local stdio = require("@lune/stdio")

-- Prompting the user for basic input
local text: string = stdio.prompt("text", "Please write some text")
local confirmed: boolean = stdio.prompt("confirm", "Please confirm this action")

-- Writing directly to stdout or stderr, without the auto-formatting of print/warn/error
stdio.write("Hello, ")
stdio.write("World! ")
stdio.write("All on the same line")
stdio.ewrite("\nAnd some error text, too")

Functions

color

function Stdio.color(color: Color)

Return an ANSI string that can be used to modify the persistent output color.

Pass "reset" to get a string that can reset the persistent output color.

Example usage:

ewrite

Writes a string directly to stderr, without any newline.

format

Formats arguments into a human-readable string with syntax highlighting for tables.

prompt

Prompts for user input using the wanted kind of prompt:

  • "text" - Prompts for a plain text string from the user

  • "confirm" - Prompts the user to confirm with y / n (yes / no)

  • "select" - Prompts the user to select one value from a list

  • "multiselect" - Prompts the user to select one or more values from a list

  • nil - Equivalent to "text" with no extra arguments

style

Return an ANSI string that can be used to modify the persistent output style.

Pass "reset" to get a string that can reset the persistent output style.

Example usage:

write

Writes a string directly to stdout, without any newline.


Types

Color

Style

Last updated