Current section
Files
Jump to
Current section
Files
simplinput
README.md
README.md
# simplinput
[](https://hex.pm/packages/simplinput)
[](https://simplinput.hexdocs.pm/)
Synchronous, cross-target stdin reading for Gleam across Erlang, Node.js, Deno, and Bun.
Requires Erlang/OTP 28+ on the Erlang target.
```sh
gleam add simplinput
```
## Usage
### Reading whole input
```gleam
import gleam/io
import simplinput
pub fn main() {
case simplinput.read() {
Ok(text) -> io.println(text)
Error(_) -> io.println_error("failed to read stdin")
}
}
```
```shell
$ echo "Hello, Joe" | gleam run
Hello, Joe
```
### Interactive CLI helpers
```gleam
import gleam/io
import simplinput
pub fn main() {
case simplinput.is_tty() {
True ->
case simplinput.prompt("Name: ") {
Ok(name) -> io.println("Hello, " <> name)
Error(_) -> Nil
}
False -> Nil
}
}
```
```shell
$ gleam run
Name: Joe
Hello, Joe
```