Skip to content

Add a beautiful help page for the CLI and clean up docs.#300

Merged
jklein24 merged 1 commit intomainfrom
03-26-add_a_beautiful_help_page_for_the_cli_and_clean_up_docs
Mar 26, 2026
Merged

Add a beautiful help page for the CLI and clean up docs.#300
jklein24 merged 1 commit intomainfrom
03-26-add_a_beautiful_help_page_for_the_cli_and_clean_up_docs

Conversation

@jklein24
Copy link
Copy Markdown
Contributor

@jklein24 jklein24 commented Mar 26, 2026

Screenshot 2026-03-26 at 1.55.50 PM.png

@jklein24 jklein24 requested a review from bsiaotickchong March 26, 2026 21:12
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 26, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
grid-flow-builder Ready Ready Preview, Comment Mar 26, 2026 9:13pm

Request Review

Copy link
Copy Markdown
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

Copy link
Copy Markdown

lol inspired by ramp?

@jklein24 jklein24 merged commit 56fabb7 into main Mar 26, 2026
8 checks passed
Copy link
Copy Markdown
Contributor Author

Merge activity

@jklein24 jklein24 deleted the 03-26-add_a_beautiful_help_page_for_the_cli_and_clean_up_docs branch March 26, 2026 21:14
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 26, 2026

Greptile Summary

This PR adds a polished, color-gradient CLI help page using a custom Commander formatter and cleans up the README to use the grid global command (installed via npm link) throughout all examples.\n\nKey changes:\n- cli/src/help.ts (new): Implements a custom formatHelp override that renders a full-width "GRID" block-character banner with a seeded Mulberry32 PRNG gradient, plus styled box-drawing sections for Options and Commands. Falls back to plain ASCII on non-TTY output.\n- cli/src/index.ts: Wires in configureHelp(program) before command registration; also adds an explicit -V, --version flag label/description.\n- cli/README.md: All node cli/dist/index.js invocations replaced with grid; adds the npm link setup step.\n- cli/package.json: Removes the \"engines\" constraint — see inline comment.\n\nMinor issues found:\n- stripAnsi is defined in help.ts but never called (dead code; may trigger a TypeScript noUnusedLocals error).\n- The --no-color flag is not consulted by the help formatter, so grid --no-color --help in a TTY still renders colorized output.\n- Removing the engines field means npm won't warn users on Node < 18 at install time.

Confidence Score: 4/5

Safe to merge — all three issues are non-blocking cosmetic/DX nits with no impact on correctness or runtime behavior.

The core change (beautiful help page + README cleanup) is well-implemented and correct. The three flagged items are all P2 style/best-practice issues: unused dead code, a minor --no-color inconsistency that only matters in a fairly rare edge case (TTY + explicit --no-color + --help), and the engines field removal which is a mild DX regression. None of these block functionality or cause runtime errors.

cli/src/help.ts for the unused stripAnsi function and the --no-color / tty() inconsistency.

Important Files Changed

Filename Overview
cli/src/help.ts New file: custom Commander help formatter with a seeded-PRNG gradient banner and Unicode box sections. Minor issues: unused stripAnsi function (dead code) and --no-color flag ignored during help rendering.
cli/src/index.ts Integrates configureHelp, adds explicit -V, --version flags, and moves configureHelp call before command registration — correct ordering with Commander.
cli/package.json Removes engines field (node: >=18.0.0), which means npm won't warn users on unsupported Node versions at install time.
cli/README.md All node cli/dist/index.js invocations replaced with the grid global command; npm link step added to setup. Clean documentation improvement.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["grid --help"] --> B{cmd.parent?}
    B -- "yes (subcommand)" --> C["Help.prototype.formatHelp\n(default Commander output)"]
    B -- "no (root command)" --> D["rootHelp(cmd)"]
    D --> E{tty?}
    E -- "no" --> F["Plain text banner\n+ --- Section --- boxes"]
    E -- "yes" --> G["Gradient block-char banner\nmulberry32 PRNG seed=42"]
    G --> H["Styled section boxes\nwith box-drawing chars"]
    F --> I["Output to stdout"]
    H --> I
    C --> I
Loading

Comments Outside Diff (1)

  1. cli/package.json, line 1-28 (link)

    P2 engines field removed — users on Node < 18 won't get a clear warning

    The diff removes "engines": { "node": ">=18.0.0" }. Commander v12 (used in dependencies) requires Node.js ≥ 18, and without the engines field npm won't surface a helpful warning at install time. Users on Node 16 will instead see a cryptic runtime error. Consider retaining this field for a better out-of-the-box experience.

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: cli/package.json
    Line: 1-28
    
    Comment:
    **`engines` field removed — users on Node < 18 won't get a clear warning**
    
    The diff removes `"engines": { "node": ">=18.0.0" }`. Commander v12 (used in `dependencies`) requires Node.js ≥ 18, and without the `engines` field npm won't surface a helpful warning at install time. Users on Node 16 will instead see a cryptic runtime error. Consider retaining this field for a better out-of-the-box experience.
    
    How can I resolve this? If you propose a fix, please make it concise.
Prompt To Fix All With AI
This is a comment left during a code review.
Path: cli/src/help.ts
Line: 123-125

Comment:
**Unused `stripAnsi` function (dead code)**

`stripAnsi` is defined but never called anywhere in this file, and it's not exported. If TypeScript is configured with `noUnusedLocals: true` this will produce a compile error. Consider removing it or using it for alignment calculations if that was the original intent (e.g., stripping ANSI codes before calling `.padEnd` — though the current code already pads before adding color codes, so it's not needed).

```suggestion
```

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: cli/src/help.ts
Line: 25-27

Comment:
**`--no-color` flag not respected in help output**

The help formatter uses `process.stdout.isTTY` to decide whether to render ANSI colors. However, the `--no-color` CLI option (which calls `setUseColors(false)` via the `preAction` hook) is never consulted here, since Commander short-circuits command execution to show help before the hook fires.

This means running `grid --no-color --help` in an interactive terminal will still produce colorized output, which users might not expect. Consider accepting a `useColors` parameter or checking a module-level flag that respects `--no-color`:

```typescript
// In help.ts, expose a setter:
let _useColors: boolean | undefined;
export function setHelpColors(v: boolean): void { _useColors = v; }

function tty(): boolean {
  return _useColors ?? (process.stdout.isTTY ?? false);
}
```

And call `setHelpColors(false)` when `--no-color` is parsed (e.g., in the `preAction` hook or immediately after option parsing).

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: cli/package.json
Line: 1-28

Comment:
**`engines` field removed — users on Node < 18 won't get a clear warning**

The diff removes `"engines": { "node": ">=18.0.0" }`. Commander v12 (used in `dependencies`) requires Node.js ≥ 18, and without the `engines` field npm won't surface a helpful warning at install time. Users on Node 16 will instead see a cryptic runtime error. Consider retaining this field for a better out-of-the-box experience.

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "Add a beautiful help page for the CLI an..." | Re-trigger Greptile

Comment on lines +123 to +125
function stripAnsi(s: string): string {
return s.replace(/\x1b\[[0-9;]*m/g, "");
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Unused stripAnsi function (dead code)

stripAnsi is defined but never called anywhere in this file, and it's not exported. If TypeScript is configured with noUnusedLocals: true this will produce a compile error. Consider removing it or using it for alignment calculations if that was the original intent (e.g., stripping ANSI codes before calling .padEnd — though the current code already pads before adding color codes, so it's not needed).

Suggested change
function stripAnsi(s: string): string {
return s.replace(/\x1b\[[0-9;]*m/g, "");
}
Prompt To Fix With AI
This is a comment left during a code review.
Path: cli/src/help.ts
Line: 123-125

Comment:
**Unused `stripAnsi` function (dead code)**

`stripAnsi` is defined but never called anywhere in this file, and it's not exported. If TypeScript is configured with `noUnusedLocals: true` this will produce a compile error. Consider removing it or using it for alignment calculations if that was the original intent (e.g., stripping ANSI codes before calling `.padEnd` — though the current code already pads before adding color codes, so it's not needed).

```suggestion
```

How can I resolve this? If you propose a fix, please make it concise.

Comment on lines +25 to +27
function tty(): boolean {
return process.stdout.isTTY ?? false;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 --no-color flag not respected in help output

The help formatter uses process.stdout.isTTY to decide whether to render ANSI colors. However, the --no-color CLI option (which calls setUseColors(false) via the preAction hook) is never consulted here, since Commander short-circuits command execution to show help before the hook fires.

This means running grid --no-color --help in an interactive terminal will still produce colorized output, which users might not expect. Consider accepting a useColors parameter or checking a module-level flag that respects --no-color:

// In help.ts, expose a setter:
let _useColors: boolean | undefined;
export function setHelpColors(v: boolean): void { _useColors = v; }

function tty(): boolean {
  return _useColors ?? (process.stdout.isTTY ?? false);
}

And call setHelpColors(false) when --no-color is parsed (e.g., in the preAction hook or immediately after option parsing).

Prompt To Fix With AI
This is a comment left during a code review.
Path: cli/src/help.ts
Line: 25-27

Comment:
**`--no-color` flag not respected in help output**

The help formatter uses `process.stdout.isTTY` to decide whether to render ANSI colors. However, the `--no-color` CLI option (which calls `setUseColors(false)` via the `preAction` hook) is never consulted here, since Commander short-circuits command execution to show help before the hook fires.

This means running `grid --no-color --help` in an interactive terminal will still produce colorized output, which users might not expect. Consider accepting a `useColors` parameter or checking a module-level flag that respects `--no-color`:

```typescript
// In help.ts, expose a setter:
let _useColors: boolean | undefined;
export function setHelpColors(v: boolean): void { _useColors = v; }

function tty(): boolean {
  return _useColors ?? (process.stdout.isTTY ?? false);
}
```

And call `setHelpColors(false)` when `--no-color` is parsed (e.g., in the `preAction` hook or immediately after option parsing).

How can I resolve this? If you propose a fix, please make it concise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants