Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@annieetang
Copy link
Contributor

@annieetang annieetang commented Oct 17, 2025

Problem

Lute did not support user input yet.

Solution

We introduce user input support to the Lute and the Lute standard library!
Users can use the input() function found in@std/io to process and store user input from command line, piped input, or file redirection. See examples below and in examples/user_input.luau.
Functionality was implemented using libuv's library and can be found in lute/io

Examples

Scripts

Get user input

local io = require("@std/io")

local input = io.input()
print(input)

Get user input with prompt

local io = require("@std/io")

local name = io.input("Please enter your name: ")
print(name)

Ways to execute the script

Command line

$ lute user_input.luau
> [will wait for user input in command line]

Piped input

$ echo hello | lute user_input.luau

Input redirected from file

$ lute user_input.luau < input_text.txt

Future Work

  • Tests
  • stdout and stderr functionality and other I/O utilities.
  • Currently, providing a prompt to the user with .input() will produce a new line between said prompt and the user input, this will most likely be resolved once stdout is implemented

Thank you @vrn-sn for massive help (esp with libuv) 🙏

Resolves #360

@annieetang annieetang self-assigned this Oct 20, 2025
Copy link
Collaborator

@Vighnesh-V Vighnesh-V left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great! I have one more comment that I think should be addressed before we can merge this in.

@annieetang annieetang requested a review from aatxe October 20, 2025 20:53
@aatxe aatxe merged commit bf5d1d4 into primary Oct 20, 2025
10 checks passed
@aatxe aatxe deleted the annietang/add_stdio branch October 20, 2025 23:20
annieetang added a commit that referenced this pull request Oct 21, 2025
Forgot to rename the `.read()` call in `definitions/io.luau` when
renaming the `input` to `read` in `io.cpp` in
#437 and was causing a type error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Add user input support to the standard library

4 participants