Skip to content

Commit 19ef2a3

Browse files
committed
Updated docs.
1 parent d8dc9c8 commit 19ef2a3

4 files changed

Lines changed: 13 additions & 10 deletions

File tree

AGENTS.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ options.bash/
9090
- **Global variables** use `module_name` prefix (e.g., `ansi_style_colors`, `args_program_name`).
9191
- **Include guards**: every module checks for a sentinel function at the top and returns early if already loaded.
9292
- **Auto-dependency loading**: modules resolve their own dependencies relative to `BASH_SOURCE`.
93-
- **No simple command name pollution** by default can be disabled by setting `ANSI_NO_SIMPLE_COMMAND_NAMES=1` before sourcing.
93+
- **Simple command names** (`RED`, `BOLD`, `RESET_ALL`, etc.) are defined by default. Suppress with `ANSI_NO_SIMPLE_COMMAND_NAMES=1` before sourcing.
9494

9595
## Architecture
9696

@@ -183,7 +183,8 @@ args::parse "$@"
183183
- Every module is independently sourceable (dependencies are auto-resolved).
184184
- `ansi.sh` and `ansi-tput.sh` are mutually exclusive — source only one.
185185
- Use `ansi::out` / `box::out` / `string::out` instead of raw `echo` for terminal-safe output.
186-
- Error output functions (`ansi::err`, `box::err`, `string::err`) write to stderr and return 1.
186+
- Warning output (`::warn`) writes to stderr and returns 0 — safe under `set -e`.
187+
- Error output (`::err`) writes to stderr and returns 1.
187188
- Wiki documentation lives in the `wiki/` submodule.
188189
- Automated tests live in `tests/` — run with `bash tests/run.sh`.
189190
- Manual tests (visual inspection) live in `tests/manual/`.

ARCHITECTURE.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ wiki/ # GitHub wiki documentation (git submodule)
3030

3131
```
3232
string.sh ← no dependencies (lowest level)
33-
34-
ansi-utils.sh ← loads string.sh (via ansi.sh or ansi-tput.sh)
33+
ansi-utils.sh ← no dependencies (shared helpers for ansi.sh / ansi-tput.sh)
3534
3635
ansi.sh ← loads ansi-utils.sh (raw escape sequences)
3736
ansi-tput.sh ← loads ansi-utils.sh (tput-based, alternative to ansi.sh)
@@ -50,9 +49,9 @@ args-completion.sh ← loads args.sh (registers args::on_options hook)
5049
| Module | Auto-loads |
5150
|---|---|
5251
| `string.sh` | _(nothing)_ |
53-
| `ansi-utils.sh` | _(nothing, but expects `string.sh` functions or degrades gracefully)_ |
54-
| `ansi.sh` | `ansi-utils.sh` `string.sh` |
55-
| `ansi-tput.sh` | `ansi-utils.sh` `string.sh` |
52+
| `ansi-utils.sh` | _(nothing)_ |
53+
| `ansi.sh` | `ansi-utils.sh` |
54+
| `ansi-tput.sh` | `ansi-utils.sh` |
5655
| `box.sh` | `string.sh` |
5756
| `args.sh` | _(nothing)_ |
5857
| `args-help.sh` | `ansi.sh`, `string.sh`, `box.sh` |
@@ -79,11 +78,11 @@ This means modules can be sourced multiple times safely, and dependency loading
7978

8079
### Terminal-aware output
8180

82-
All output functions (`ansi::out`, `box::out`, `string::out`) detect whether stdout/stderr is a terminal:
81+
Output functions detect whether stdout/stderr is a terminal:
8382
- **Terminal**: output includes ANSI escape codes.
8483
- **Pipe/file**: escape codes are automatically stripped.
8584

86-
The check is `[[ -t 1 || -z "$TERM" ]]` (fd 1 for stdout, fd 2 for stderr).
85+
Stdout functions (`::out`): check `[[ -t 1 || -z "$TERM" ]]`. Stderr functions (`::err`, `::warn`): check `[[ -t 2 || -z "$TERM" ]]`. `::err` returns 1 (signals failure); `::warn` returns 0 (safe under `set -e`).
8786

8887
### ANSI implementations
8988

llms.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ String utilities. No dependencies.
4040
- `string::make_pad LENGTH [CHAR]` — create a padding string of given length.
4141
- `string::pad STRING LENGTH [ALIGN] [CHAR]` — pad string to length. ALIGN: `left`/`l`, `right`/`r`, `center`/`c`.
4242
- `string::out ARGS...` — terminal-aware echo (strips ANSI when piped).
43+
- `string::warn ARGS...` — terminal-aware echo to stderr (returns 0, safe under `set -e`).
4344
- `string::err ARGS...` — terminal-aware echo to stderr (returns 1).
4445

4546
### ansi-utils.sh
@@ -60,6 +61,7 @@ Shared ANSI utilities loaded by both `ansi.sh` and `ansi-tput.sh`.
6061
- `ansi::strip STRING` — remove all ANSI escape codes.
6162
- `ansi::length STRING` — visible string length (after stripping ANSI).
6263
- `ansi::out ARGS...` — terminal-aware echo (strips ANSI when piped).
64+
- `ansi::warn ARGS...` — terminal-aware echo to stderr (returns 0, safe under `set -e`).
6365
- `ansi::err ARGS...` — terminal-aware echo to stderr (returns 1).
6466
- `ansi::prompt ARGS...` — like `ansi::out` but no trailing newline.
6567

@@ -183,6 +185,7 @@ Text box layout engine for multi-line strings. Loads `string.sh`.
183185
- `box::stack_lr STRING1 STRING2` — stack side-by-side (must have equal height).
184186
- `box::stack_tb STRING1 STRING2` — stack vertically (must have equal width).
185187
- `box::out STRING` — terminal-aware multi-line output.
188+
- `box::warn STRING` — terminal-aware multi-line output to stderr (returns 0, safe under `set -e`).
186189
- `box::err STRING` — terminal-aware multi-line output to stderr (returns 1).
187190

188191
## Bootstrap pattern

wiki

Submodule wiki updated from 51f8234 to 409e5b9

0 commit comments

Comments
 (0)