EAPI=8

DESCRIPTION="An agentic coding tool that lives in your terminal"
HOMEPAGE="https://github.com/anthropics/claude-code"
SRC_URI="https://downloads.claude.ai/claude-code-releases/${PV}/linux-x64/claude -> ${P}"

LICENSE="all-rights-reserved"
SLOT="0"
KEYWORDS="~amd64"
RESTRICT="mirror bindist"

RDEPEND="
  app-shells/bash
  dev-vcs/git
  sys-apps/ripgrep
  net-misc/wget
"
BDEPEND=""
S="${WORKDIR}/${P}"

QA_PREBUILT="opt/claude-code/bin/claude"

src_unpack() {
  mkdir -p "${S}"
  cp "${DISTDIR}/${P}" "${S}/claude"
}

src_install() {
  exeinto /opt/claude-code/bin
  newexe "${S}/claude" claude

  dosym /opt/claude-code/bin/claude /usr/bin/claude

  newenvd "${FILESDIR}/50claude-code" 50claude-code
}