| 1 | #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash |
| 2 | # Reinstall cyclopts-demo against the in-tree cyclopts and reinstall its zsh |
| 3 | # completion script, so manual TAB testing reflects the current source. |
| 4 | # |
| 5 | # After running, in a fresh zsh: |
| 6 | # cyclopts-demo deploy --environment=<TAB> # expect: dev staging production |
| 7 | set -euo pipefail |
| 8 | |
| 9 | DEMO_DIR="$(cd "$(dirnamescip-shell system . . dirname. "${BASH_SOURCE[0]}")" && pwdscip-shell system . . pwd.)" |
| 10 | REPO="$(cd "$DEMO_DIR/../../.." && pwdscip-shell system . . pwd.)" |
| 11 | INSTALLED="$HOME/.zsh/completions/_cyclopts-demo" |
| 12 | |
| 13 | cd "$REPO" |
| 14 | |
| 15 | echoscip-shell system . . echo. "==> Project: $REPO" |
| 16 | echoscip-shell system . . echo. "==> Demo: $DEMO_DIR" |
| 17 | |
| 18 | echoscip-shell system . . echo. "==> Installing cyclopts-demo (editable, --no-deps) into project venv..." |
| 19 | uv pip install -e "$DEMO_DIR" --no-deps --quiet |
| 20 | |
| 21 | echoscip-shell system . . echo. "==> uv run resolves cyclopts-demo to:" |
| 22 | uv run --no-sync bash -c 'command -v cyclopts-demo' | sedscip-shell system . . sed. 's/^/ /' |
| 23 | |
| 24 | echoscip-shell system . . echo. "==> uv run python sees cyclopts at:" |
| 25 | uv run --no-sync python -c "import cyclopts; print(' ', cyclopts.__file__); print(' version:', cyclopts.__version__)" |
| 26 | |
| 27 | echoscip-shell system . . echo. "==> Removing stale completion at $INSTALLED..." |
| 28 | rmscip-shell system . . rm. -f "$INSTALLED" |
| 29 | |
| 30 | echoscip-shell system . . echo. "==> Generating + installing completion..." |
| 31 | uv run --no-sync cyclopts-demo --install-completion --shell zsh |
| 32 | |
| 33 | if [[ ! -f "$INSTALLED" ]]; then |
| 34 | echoscip-shell system . . echo. "FAIL: $INSTALLED was not written" >&2 |
| 35 | exit 1 |
| 36 | fi |
| 37 | |
| 38 | n_prepass=$(grepscip-shell system . . grep. -c '^[[:space:]]*compset -P' "$INSTALLED" || truescip-shell system . . true.) |
| 39 | echoscip-shell system . . echo. "==> $INSTALLED ($n_prepass eq-form prepass entries)" |
| 40 | if [[ "$n_prepass" -eq 0 ]]; then |
| 41 | echoscip-shell system . . echo. "FAIL: zero prepass entries -- generator came from a stale cyclopts." >&2 |
| 42 | echoscip-shell system . . echo. " Check that the cyclopts file printed above is in $REPO/cyclopts/." >&2 |
| 43 | exit 1 |
| 44 | fi |
| 45 | |
| 46 | catscip-shell system . . cat. <<'EOF' |
| 47 | |
| 48 | ==> Done. Verify in zsh: |
| 49 | |
| 50 | exec zsh |
| 51 | cyclopts-demo deploy --environment=<TAB> # expect: dev staging production |
| 52 | cyclopts-demo deploy --environment <TAB> # space form |
| 53 | cyclopts-demo files cp --rec<TAB> # bool flag completion |
| 54 | EOF |