CLI

Library for interacting with the command-line.


Source: pkg/lua/lib/cli.go | Import: cli

Functions


clear

clear()

Clears the console screen.

clear_line

clear_line()

Clears the current line in the console.

print

print(msg...)

This is also including in the log similar to std.log.

Arguments

  • msg string... - The messages to print to the console.
printf

printf(msg, args...)

This is also including in the log similar to std.log.

Arguments

  • msg string - The message to print to the console.
  • args any... - The arguments to format the message with.
println

println(msg?)

This is also including in the log similar to std.log.

Arguments

  • msg string - The message to print to the console.
printlnf

printlnf(msg, args...)

This is also including in the log similar to std.log.

Arguments

  • msg string - The message to print to the console.
  • args any... - The arguments to format the message with.
print_float

print_float(numbers...)

This is also including in the log similar to std.log.

Arguments

  • numbers float64... - The numbers to print to the console.
print_int

print_int(numbers...)

This is also including in the log similar to std.log.

Arguments

  • numbers int... - The numbers to print to the console.
println_number

println_number(number, trunc?)

This is also including in the log similar to std.log.

Arguments

  • number float64 - The number to print to the console.
  • trunc bool
print_table

print_table(table)

Arguments

  • table table<any> - The table to print to the console.
print_image

print_image(id, double?, alpha?)

@blocking
Arguments

  • id int<collection.IMAGE>
  • double bool - If true, use 2 characters per pixel.
  • alpha int - Remove pixels with an alpha below this value.
print_image_inline

print_image_inline(id) -> bool

@blocking

Prints the image using the inline graphics protocol, if available. Returns false if this feature in unavailable.

Arguments

  • id int<collection.IMAGE>
Return Values

  • bool
print_image_inline_kitty

print_image_inline_kitty(id, opts) -> bool

@blocking

Prints the image using kitty's inline graphics protocol, if available. Returns false if this feature in unavailable.

Arguments

  • id int<collection.IMAGE>
  • opts struct<cli.KittyOpts>
Return Values

  • bool
string_image

string_image(id, double?, alpha?) -> string

@blocking
Arguments

  • id int<collection.IMAGE>
  • double bool - If true, use 2 characters per pixel.
  • alpha int - Remove pixels with an alpha below this value.
Return Values

  • string
print_image_size

print_image_size(id, width, height, double?, alpha?)

@blocking
Arguments

  • id int<collection.IMAGE>
  • width int - The width of the image.
  • height int - The height of the image.
  • double bool - If true, use 2 characters per pixel.
  • alpha int - Remove pixels with an alpha below this value.
string_image_size

string_image_size(id, width, height, double?, alpha?) -> string

@blocking
Arguments

  • id int<collection.IMAGE>
  • width int - The width of the image.
  • height int - The height of the image.
  • double bool - If true, use 2 characters per pixel.
  • alpha int - Remove pixels with an alpha below this value.
Return Values

  • string
print_color

print_color(c, double?)

Arguments

  • c struct<color> - The color to print.
  • double bool - If true, use 2 characters per pixel.
println_color

println_color(c, double?)

Arguments

  • c struct<color> - The color to print.
  • double bool - If true, use 2 characters per pixel.
progress

progress(current, total, width, title, bar?, empty?, noreset?)

Arguments

  • current int - The current step.
  • total int - The total number of steps.
  • width int - The width of the progress bar.
  • title string - The title of the progress bar.
  • bar string - The character to use for the progress bar, default is '#'.
  • empty string - The character to use for the empty space, default is ' '.
  • noreset bool - If true, the progress bar will not reset to the beginning of the line. If false, it will print a newline after the progress bar.
question

question(question) -> string

Arguments

  • question string - The message to be displayed.
Return Values

  • string - The answer given by the user.
question_ext

question_ext(question, options) -> string

Arguments

  • question string - The message to be displayed.
  • options struct<cli.Options> - Options used for processing the response.
Return Values

  • string - The answer given by the user.
confirm

confirm(msg)

Waits for the user to press enter before continuing.

Arguments

  • msg string - The message to be displayed.
select

select(msg, options) -> int

Arguments

  • msg string - The message to be displayed.
  • options []string - List of options for the user to select from.
Return Values

  • int - The index of selected option, or 0 if none were picked.
color_256

color_256(code) -> string

Arguments

  • code int
Return Values

  • string - The color control code.
color_true

color_true(red, green, blue) -> string

Arguments

  • red int
  • green int
  • blue int
Return Values

  • string - The color control code.
color_bg_256

color_bg_256(code) -> string

Arguments

  • code int
Return Values

  • string - The color control code.
color_bg_true

color_bg_true(red, green, blue) -> string

Arguments

  • red int
  • green int
  • blue int
Return Values

  • string - The color control code.
cursor_up

cursor_up(n) -> string

Arguments

  • n int
Return Values

  • string - The cursor control code.
cursor_down

cursor_down(n) -> string

Arguments

  • n int
Return Values

  • string - The cursor control code.
cursor_right

cursor_right(n) -> string

Arguments

  • n int
Return Values

  • string - The cursor control code.
cursor_left

cursor_left(n) -> string

Arguments

  • n int
Return Values

  • string - The cursor control code.
cursor_pos

cursor_pos(x, y) -> string

Arguments

  • x int
  • y int
Return Values

  • string - The cursor control code.
cursor_next_line

cursor_next_line(n) -> string

Arguments

  • n int
Return Values

  • string - The cursor control code.
cursor_prev_line

cursor_prev_line(n) -> string

Arguments

  • n int
Return Values

  • string - The cursor control code.
cursor_column

cursor_column(n) -> string

Arguments

  • n int
Return Values

  • string - The cursor control code.
bell

bell()

is_kitty

is_kitty() -> bool

Return Values

  • bool
is_iterm

is_iterm() -> bool

Return Values

  • bool
is_tmux

is_tmux() -> bool

Return Values

  • bool

Constants


Control
  • RESET
  • BELL
TextColor
  • BLACK
  • RED
  • GREEN
  • YELLOW
  • BLUE
  • MAGENTA
  • CYAN
  • WHITE
  • BRIGHT_BLACK
  • BRIGHT_RED
  • BRIGHT_GREEN
  • BRIGHT_YELLOW
  • BRIGHT_BLUE
  • BRIGHT_MAGENTA
  • BRIGHT_CYAN
  • BRIGHT_WHITE
BackgroundColor
  • BACKGROUND_BLACK
  • BACKGROUND_RED
  • BACKGROUND_GREEN
  • BACKGROUND_YELLOW
  • BACKGROUND_BLUE
  • BACKGROUND_MAGENTA
  • BACKGROUND_CYAN
  • BACKGROUND_WHITE
  • BRIGHT_BACKGROUND_BLACK
  • BRIGHT_BACKGROUND_RED
  • BRIGHT_BACKGROUND_GREEN
  • BRIGHT_BACKGROUND_YELLOW
  • BRIGHT_BACKGROUND_BLUE
  • BRIGHT_BACKGROUND_MAGENTA
  • BRIGHT_BACKGROUND_CYAN
  • BRIGHT_BACKGROUND_WHITE
Style
  • BOLD
  • UNDERLINE
  • REVERSED
Cursor
  • CURSOR_HOME
  • CURSOR_LINEUP
  • CURSOR_SAVE
  • CURSOR_LOAD
  • CURSOR_INVISIBLE
  • CURSOR_VISIBLE
Erase
  • ERASE_DOWN
  • ERASE_UP
  • ERASE_SCREEN
  • ERASE_SAVED
  • ERASE_LINE_END
  • ERASE_LINE_START
  • ERASE_LINE

Structs


KittyOpts

Properties

  • x int - The x position of the image.
  • y int - The y position of the image.
  • width int - The width of the image.
  • height int - The height of the image.
  • offsetx int - The pixel x offset of the image.
  • offsety int - The pixel y offset of the image.
  • cols int - Width in terminal columns.
  • rows int - Height in terminal rows.
  • zindex int - The z-index of the image.
  • imageId int
  • imageNo int
  • placementId int
Options

Properties

  • normalize bool - Set to lowercase the recieved answer.
  • accepts []string - List of accepted responses.
  • fallback string - A default response to return when the one entered by the user is not in 'accepts'.