cli_fmt 0.9.2

CLI output formatting utilities for command-line applications
Documentation
# Fill remaining test coverage gaps — is_default tail/width, tty_detect non-TTY, data_fmt absence

## Execution State

- **Executor Type:** any
- **Actor:** null
- **Claimed At:** null
- **Reopen Count:** 0
- **State:** ✅ (Completed)
- **Closes:** null
- **Blocked Reason:** null
- **Dir:** .
- **Validated By:** Level-3-PASS(58/58 nextest, 4 doc, 0 clippy)
- **Validation Date:** 2026-06-06

## Goal

Close the 4 remaining ⏳ test coverage gaps in `cli_fmt` (FT-24, FT-25, FT-10, FT-11) identified by the test-surface audit of 2026-06-06, so that every spec case has a corresponding passing test and the spec files contain zero ⏳ markers (Motivated: `is_default()` is documented to check all 6 `OutputConfig` fields but only 3 are independently verified — tail and width have no `is_default` discriminant tests; tty_detect=true behavior in non-TTY is a documented API guarantee with no test; data_fmt exclusion is AC-4 of feature/002 with no automated check; Observable: `cargo nextest run --all-features` passes with 4 new tests; ⏳ markers in FT-24/FT-25 of `tests/docs/feature/001_output_processing.md` and FT-10/FT-11 of `tests/docs/feature/002_cli_help_template.md` replaced with ✅-equivalent test function names; Scoped: `tests/output.rs`, `tests/help.rs`, and 2 spec files only — no `src/` changes; Testable: `w3 .test l::3` passes).

## In Scope

- `tests/output.rs` — add `is_default_tail`: assert `!OutputConfig::default().with_tail(2).is_default()` (FT-24)
- `tests/output.rs` — add `is_default_width`: assert `!OutputConfig::default().with_width(5).is_default()` (FT-25)
- `tests/help.rs` — add `test_tty_detect_true_suppresses_ansi_in_non_tty`: render with default style (`tty_detect=true`) in test environment (non-TTY stdout) and assert no ANSI codes in output (FT-10)
- `tests/help.rs` — add `test_no_data_fmt_dependency`: read `Cargo.toml` as text and assert the string `"data_fmt"` does not appear as a dependency (FT-11)
- `tests/docs/feature/001_output_processing.md` — replace ⏳ in FT-24 and FT-25 `### Tests` entries with implemented test function names
- `tests/docs/feature/002_cli_help_template.md` — replace ⏳ in FT-10 and FT-11 `### Tests` entries with implemented test function names

## Out of Scope

- Source code changes to `src/output.rs` or `src/help.rs` — all tests must pass against the current implementation
- Documentation changes to `docs/` — already updated to consistency in the doc_tsk Step 2 pass (2026-06-06)
- Tests already implemented (FT-1..FT-23, FT-26..FT-33, AP-1..AP-7)
- Performance benchmarks or manual testing

## Requirements

- All work must strictly adhere to all applicable rulebooks (`kbase .rulebooks`)
- 2-space indentation per code_style.rulebook.md
- Tests must be added to existing integration test files (no new test files)
- No mocking — use real Cargo.toml parsing (read file as string, assert substring absent)
- Tests must fail loudly with descriptive assert messages
- Each new test must be referenced in the corresponding spec file `### Tests` row

## Work Procedure

Execute in order. Do not skip or reorder steps.

1. **Read spec files** — Read `tests/docs/feature/001_output_processing.md` (FT-24, FT-25) and `tests/docs/feature/002_cli_help_template.md` (FT-10, FT-11) to confirm the Given/When/Then contract for each test.
2. **Write output tests (FT-24/FT-25)** — In `tests/output.rs`, append after the existing `is_default_unicode_aware` test:
   - `is_default_tail`: `OutputConfig::default().with_tail(2)`, assert `!config.is_default()`
   - `is_default_width`: `OutputConfig::default().with_width(5)`, assert `!config.is_default()`
3. **Run output tests** — `cargo test --test output --all-features` — both new tests must pass.
4. **Write help tests (FT-10/FT-11)** — In `tests/help.rs`, append after `test_opt_name_not_truncated`:
   - `test_tty_detect_true_suppresses_ansi_in_non_tty`: construct `CliHelpTemplate::new(CliHelpStyle::default(), two_group_data()).render()` and assert `!out.contains("\x1b[")` — test processes run without a TTY so `tty_detect=true` must suppress colors
   - `test_no_data_fmt_dependency`: read `include_str!("../Cargo.toml")`, assert `!contents.contains("data_fmt")`
5. **Run help tests** — `cargo test --test help --all-features --features cli_help_template` — both new tests must pass.
6. **Update spec Tests tables** — In each spec file, update the `### Tests` row to replace ⏳ with the actual test function name for FT-24, FT-25, FT-10, FT-11.
7. **Run Level 3** — `w3 .test l::3` — must pass with 0 failures and 0 clippy warnings.
8. **Verify test count** — `cargo nextest run --all-features 2>&1 | grep passed` — should show 58 tests.

## Test Matrix

| # | Input Scenario | Config Under Test | Expected Behavior |
|---|----------------|-------------------|-------------------|
| T01 | `OutputConfig::default().with_tail(2)` | `is_default()` | returns `false` — tail field deviates from `None` |
| T02 | `OutputConfig::default().with_width(5)` | `is_default()` | returns `false` — width field deviates from `0` |
| T03 | `CliHelpStyle::default()` (tty_detect=true), test environment (non-TTY stdout) | `render()` | no `"\x1b["` sequences — TTY probe returns false in test runner |
| T04 | `include_str!("../Cargo.toml")` | string contains check | `"data_fmt"` absent — cli_fmt renders with strs_tools primitives only |

## Acceptance Criteria

- 2 new test functions exist in `tests/output.rs`: `is_default_tail`, `is_default_width`
- 2 new test functions exist in `tests/help.rs`: `test_tty_detect_true_suppresses_ansi_in_non_tty`, `test_no_data_fmt_dependency`
- All new tests are mapped in spec files with their function names (no ⏳ remaining)
- `cargo nextest run --all-features` passes with 0 failures (58 total)
- `cargo clippy --all-targets --all-features -- -D warnings` produces 0 warnings

## Validation

### Checklist

Desired answer for every question is YES.

**is_default discriminants (FT-24/FT-25)**
- [x] C1 — Does `is_default_tail` assert `!config.is_default()` after `with_tail(2)`?
- [x] C2 — Does `is_default_width` assert `!config.is_default()` after `with_width(5)`?

**tty_detect non-TTY (FT-10)**
- [x] C3 — Does `test_tty_detect_true_suppresses_ansi_in_non_tty` use `CliHelpStyle::default()` (not a custom style)?
- [x] C4 — Does the test assert `!out.contains("\x1b[")`?

**data_fmt absence (FT-11)**
- [x] C5 — Does `test_no_data_fmt_dependency` read the actual `Cargo.toml` (not a hardcoded string)?
- [x] C6 — Does the test assert `"data_fmt"` is absent?

**Spec alignment**
- [x] C7 — Are FT-24 and FT-25 in `tests/docs/feature/001_output_processing.md` updated with test function names?
- [x] C8 — Are FT-10 and FT-11 in `tests/docs/feature/002_cli_help_template.md` updated with test function names?

**Test suite**
- [x] C9 — Does `cargo nextest run --all-features` pass with 0 failures?
- [x] C10 — Does `cargo clippy --all-targets --all-features -- -D warnings` pass?

**Out of Scope confirmation**
- [x] C11 — Are `src/output.rs` and `src/help.rs` unchanged (no production code edits)?

### Measurements

- [x] M1 — test count: `cargo nextest run --all-features 2>&1 | grep "passed"` → 58 tests
- [x] M2 — new output tests: `grep -c "fn is_default_tail\|fn is_default_width" tests/output.rs` → `2`
- [x] M3 — new help tests: `grep -c "fn test_tty_detect_true\|fn test_no_data_fmt" tests/help.rs` → `2`

### Invariants

- [x] I1 — full test suite: `w3 .test level::3` → 0 failures
- [x] I2 — compiler clean: `RUSTFLAGS="-D warnings" cargo check --all-features` → 0 warnings

## Related Documentation

- `tests/docs/feature/001_output_processing.md` — output feature test spec; FT-24 and FT-25 are the ⏳ gaps
- `tests/docs/feature/002_cli_help_template.md` — help feature test spec; FT-10 and FT-11 are the ⏳ gaps
- `docs/feature/001_output_processing.md` — OutputConfig behavioral requirements; `is_default()` field coverage
- `docs/feature/002_cli_help_template.md` — help template requirements; AC-3 (tty_detect=true) and AC-4 (no data_fmt)
- `docs/api/001_output_api.md` — output API contract; `is_default()` checks all 6 fields
- `docs/api/002_help_api.md` — help API contract; `tty_detect` suppression rule

## History

- **[2026-06-06]** `CREATED` — Task filed from test-surface audit findings. Goal: close 4 remaining ⏳ spec cases (FT-24, FT-25, FT-10, FT-11) after task 003 closed 12 prior gaps.
- **[2026-06-06]** `VERIFIED` — All 4 MAAV gates PASS.
- **[2026-06-06]** `COMPLETED` — All 4 tests implemented and passing (58/58 nextest, 4 doc, 0 clippy). FT-24/FT-25 ⏳ markers removed from spec headers. FT-10/FT-11 mapped to test function names. feature/readme.md Status → ✅.

## Verification Record

- **VG-1 (Scope Coherence):** PASS — In/Out-of-Scope non-empty, concrete, consistent; confirmed FT-24/FT-25/FT-10/FT-11 ⏳ markers present in spec files; confirmed 4 test functions absent from implementation files.
- **VG-2 (MOST Goal Quality):** PASS — all 4 MOST dimensions present and substantive; observable outcome is binary and grep-checkable; testable command is Level-3 with quantified count.
- **VG-3 (Value/YAGNI Adversarial):** PASS — all 4 adversarial challenges failed; `is_default()` confirmed to check `tail` and `width` fields (output.rs:206-214); `data_fmt` confirmed absent from Cargo.toml; tty_detect=true non-TTY is the only test exercising TTY-probe code path; no YAGNI.
- **VG-4 (Implementation Readiness):** PASS — all method names verified in source (`with_tail`, `with_width`, `is_default` at output.rs:159/166/206); `include_str!("../Cargo.toml")` path validated; `two_group_data()` helper available in same file scope; all 4 Test Matrix rows present.