( #!/bin/bash set -eu umask 077 if [[ "$(uname -s)" != Darwin ]]; then echo 'This installer is for macOS.' >&2; exit 1; fi workspace="$(mktemp -d)" trap 'rm -rf "$workspace"' EXIT printf 'Chronicle CLI team password (typing is hidden): ' >/dev/tty IFS= read -rs credential /dev/tty if [[ ! "$credential" =~ ^[A-Za-z0-9_-]{32,128}$ ]]; then echo 'Invalid password format. Run the installer again.' >&2; exit 1; fi printf 'Downloading Chronicle CLI…\n' if ! printf 'header = "Authorization: Bearer %s"\n' "$credential" | /usr/bin/curl --config - --proto '=https' -fsS https://chronicle-2-cli.sebastian-32e.workers.dev/chronicle-mac.zip -o "$workspace/cli.zip"; then echo 'Download failed. Check the CLI team password and your connection.' >&2; exit 1 fi actual="$(/usr/bin/shasum -a 256 "$workspace/cli.zip")" if [[ "${actual%% *}" != '81d11064ab021d43e78c9ed027c398b7d6c8da16ffde82391c34e98e3ff8951d' ]]; then echo 'Package and installer versions differ. Download /install again.' >&2; exit 1; fi /usr/bin/ditto -x -k "$workspace/cli.zip" "$workspace" "$workspace/Chronicle CLI/Install Chronicle.command" if [[ -n "${CHRONICLE_PROFILE_DIR:-}" ]]; then launcher="$CHRONICLE_PROFILE_DIR/bin/chronicle"; else launcher="$HOME/.local/bin/chronicle"; fi printf '%s' "$credential" | "$launcher" login --stdin unset credential if command -v chronicle >/dev/null; then echo 'Ready. Type chronicle to start.'; else echo 'Ready. Open a new Terminal window and type chronicle.'; fi )