Debian Codegraph @

tests/apps/cyclopts-demo/install.sh

raw symbols SCIP
1 #!/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 "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
10 REPO="$(cd "$DEMO_DIR/../../.." && pwd)"
11 INSTALLED="$HOME/.zsh/completions/_cyclopts-demo"
12
13 cd "$REPO"
14
15 echo "==> Project: $REPO"
16 echo "==> Demo: $DEMO_DIR"
17
18 echo "==> Installing cyclopts-demo (editable, --no-deps) into project venv..."
19 uv pip install -e "$DEMO_DIR" --no-deps --quiet
20
21 echo "==> uv run resolves cyclopts-demo to:"
22 uv run --no-sync bash -c 'command -v cyclopts-demo' | sed 's/^/ /'
23
24 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 echo "==> Removing stale completion at $INSTALLED..."
28 rm -f "$INSTALLED"
29
30 echo "==> Generating + installing completion..."
31 uv run --no-sync cyclopts-demo --install-completion --shell zsh
32
33 if [[ ! -f "$INSTALLED" ]]; then
34 echo "FAIL: $INSTALLED was not written" >&2
35 exit 1
36 fi
37
38 n_prepass=$(grep -c '^[[:space:]]*compset -P' "$INSTALLED" || true)
39 echo "==> $INSTALLED ($n_prepass eq-form prepass entries)"
40 if [[ "$n_prepass" -eq 0 ]]; then
41 echo "FAIL: zero prepass entries -- generator came from a stale cyclopts." >&2
42 echo " Check that the cyclopts file printed above is in $REPO/cyclopts/." >&2
43 exit 1
44 fi
45
46 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