Skip to content

Commit f3c0450

Browse files
authored
docs(tty): enhance tty documentation with installation and examples
Added installation instructions and a quick start example for using tty.
1 parent 43ac12c commit f3c0450

1 file changed

Lines changed: 27 additions & 13 deletions

File tree

docs/src/tty/index.md

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,34 @@
22

33
`tty` provides small cross-platform Lua bindings for terminal inspection.
44

5-
## Compatibility
5+
Compatible with Lua 5.1, 5.2, 5.3, 5.4, 5.5, and LuaJIT.
66

7-
`tty` supports:
7+
Use `tty` to detect whether streams, file handles, or file descriptors are
8+
attached to a terminal, and to read terminal rows and columns for CLI output.
89

9-
- Lua 5.1
10-
- Lua 5.2
11-
- Lua 5.3
12-
- Lua 5.4
13-
- Lua 5.5
14-
- LuaJIT
10+
## Install
1511

16-
## Use Cases
12+
::: code-group
1713

18-
- Detect whether standard streams are attached to a terminal.
19-
- Check Lua file handles and numeric file descriptors.
20-
- Read terminal rows and columns for command-line output.
21-
- Build terminal-aware Lua tools.
14+
```sh [LuaRocks]
15+
luarocks install tty
16+
```
17+
18+
:::
19+
20+
## Quick Start
21+
22+
::: code-group
23+
24+
```lua [exmaple.lua]
25+
local tty = require "tty"
26+
27+
if tty.isatty(io.stdout) then
28+
local rows, cols = tty.size()
29+
print(("terminal: %dx%d"):format(cols, rows))
30+
else
31+
print("stdout is redirected")
32+
end
33+
```
34+
35+
:::

0 commit comments

Comments
 (0)