You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/docs/aesh/table.md
+15-4Lines changed: 15 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -257,13 +257,14 @@ This wraps each border character with the ANSI color prefix and `ANSI.RESET` suf
257
257
258
258
## Using Tables in Commands
259
259
260
-
A complete command that renders tabular output:
260
+
Inside a command's `execute()` method, the `CommandInvocation` gives you access to the `Shell` object via `getShell()`. From the `Shell` you can get the current terminal dimensions with `size()` and write output with `write()` or `writeln()`. This makes it straightforward to render tables that adapt to the user's terminal:
Using `invocation.getShell().size().getWidth()` adapts the table to the current terminal width.
294
+
The key calls in the chain:
295
+
296
+
| Call | Returns | Purpose |
297
+
|------|---------|---------|
298
+
|`invocation.getShell()`|`Shell`| Access the terminal |
299
+
|`shell.size()`|`Size`| Get terminal dimensions |
300
+
|`size.getWidth()`|`int`| Terminal width in columns |
301
+
|`shell.writeln(text)`|`void`| Write output to the terminal |
302
+
303
+
This ensures the table fits the user's terminal regardless of window size. See the [CommandInvocation API](command-invocation) documentation for the full set of `Shell` methods available.
0 commit comments