idx-cli/web/scripts/gen-cli-reference.sh
hermes e6805474f5 feat(web): idx website and user docs (Astro Starlight)
Landing page plus docs for install, quickstart, config, the stocks and
ownership CLI, output and exit codes, the MCP server and per-agent setup,
agent usage, and an agent-led install page (agents/install.md) that a
coding agent follows from a one-line prompt.

- Every docs page is also served as Markdown at <path>.md; llms.txt and
  llms-full.txt come from starlight-llms-txt; a SKILL.md for skill-based
  harnesses is under /skills/idx/.
- The CLI reference and MCP tools pages are generated from idx --help and
  the tools golden; a new web-generated flake check fails when they drift.
- nix develop .#web provides bun; Cloudflare Pages builds web/ on pushes.
- Package homepage metadata points at https://idx.rasyidanaf.com.
- .cloudflare/ (the cf CLI's account cache) is git-ignored.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-15 05:12:45 +00:00

58 lines
1.4 KiB
Bash
Executable file

#!/usr/bin/env bash
# Writes the CLI reference page from `idx --help` output, walking every
# subcommand. `nix flake check` runs it against the packaged binary and fails
# when the committed page is out of date.
#
# web/scripts/gen-cli-reference.sh <idx-binary> > web/src/content/docs/cli/reference.md
set -euo pipefail
idx=${1:?usage: gen-cli-reference.sh <idx-binary>}
subcommands() {
"$idx" "$@" --help | awk '
/^Commands:/ { in_cmds = 1; next }
in_cmds && /^[^ ]/ { exit }
in_cmds && /^ [a-z]/ { if ($1 != "help") print $1 }
'
}
section() {
local depth=$1
shift
local hashes
hashes=$(printf '#%.0s' $(seq 1 "$depth"))
# shellcheck disable=SC2016 # backticks are Markdown, not command substitution
printf '%s `idx %s`\n\n```text\n' "$hashes" "$*"
"$idx" "$@" --help
printf '```\n\n'
local sub
for sub in $(subcommands "$@"); do
section $((depth + 1)) "$@" "$sub"
done
}
main() {
cat <<'EOF'
---
title: Command reference
description: Every idx command and flag, generated from idx --help.
---
<!-- Generated by web/scripts/gen-cli-reference.sh; do not edit by hand. -->
This page is generated from `idx --help`, so it always matches the released
CLI. For explanations and examples, see the [stocks](/cli/stocks/) and
[ownership](/cli/ownership/) guides.
## `idx`
```text
EOF
"$idx" --help
printf '```\n\n'
for group in $(subcommands); do
section 2 "$group"
done
}
main | sed -e 's/[[:space:]]*$//' -e '${/^$/d}'