# Copyright 2026 Nadeŭka <me+oss@nadevko.cc>
# Distributed under the terms of the GNU General Public License v2
EAPI=9

inherit go-module

DESCRIPTION='Prompt theme engine for any shell'
HOMEPAGE='
	https://ohmyposh.dev
	https://github.com/JanDeDobbeleer/oh-my-posh
'
BASE_URI=https://github.com/JanDeDobbeleer/${PN}
SRC_URI="
	${BASE_URI}/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz
	${BASE_URI}/releases/download/v${PV}/${P}-deps.tar.xz
"
LICENSE=MIT

SLOT=0
KEYWORDS=amd64
IUSE=+themes

BDEPEND='>=dev-lang/go-1.26.0'

src_unpack() {
	local -x TAR_OPTIONS='--warning=no-unknown-keyword'
	default
	ln -sf gomodcache "${WORKDIR}"/go-mod || die
}

src_compile() {
	ego build -C src -o "${S}"/oh-my-posh .
}

src_test() {
	ego test -C src -v ./...
}

src_install() {
	dobin oh-my-posh
	einstalldocs

	if use themes; then
		insinto /usr/share/oh-my-posh/themes
		doins themes/*.json
	fi
}