Name:       transifex-cli
Version:    1.6.17
Release:    1%{?dist}
License:    Apache 2.0
Group:      Networking/WWW
Summary:    The Transifex command-line client
Summary(eo):La komandlinia kliento de Transifex
URL:        https://github.com/transifex/cli
Source0:    https://github.com/transifex/cli/archive/v%{version}/cli-%{version}.tar.gz
# Generate with `go mod vendor`
Source1:    %{name}-%{version}-vendor.tar.xz
Patch0:     tx-cli-fix-typo-in-readme.diff
Patch1:     tx-cli-xdg.diff

BuildRequires: elfutils
BuildRequires: golang >= 1.16

Obsoletes: transifex-client <= 0.14.4
# python-afdko also supplies /usr/bin/tx
Conflicts: python3dist(afdko)

%prep
%autosetup -a1 -p1 -n cli-%{version}

%description
The Transifex Command-line Client is a command line tool that enables you
to easily manage your translations within a project without the need of
an elaborate UI system, by using Transifex hosted services, or your own
instance.

You can use the command line client to easily create new resources, map locale
files to translations and synchronize your Transifex project with your local
repository and vice versa. Translators and localization managers can also
use it to handle large volumes of translation files easily and without much
hassle.

You can migrate configurations from the old transifex-client by `tx mg`.

%build
# -linkmode=external is needed so that rpmbuild doesn't throw an error about a
# missing build ID.
# The other sets the version, so that `tx -v`/`tx --version` will actually
# print the version rather than giving the error "Incorrect Usage. flag
# provided but not defined: -v" (and so that the version will be displayed on
# the help screen).
go build -ldflags "-linkmode=external -X 'github.com/transifex/cli/internal/txlib.Version=%{version}'" -mod vendor -o ./bin/tx

#check
bin/tx -v

%install
# Decompress the ELF file so that rpmbuild can extract debug information.
eu-elfcompress --type=none bin/tx
mkdir -p %{buildroot}%{_bindir}
# Move to something like tx-cli or txc to avoid conflict with python-afdko?
mv bin/tx %{buildroot}%{_bindir}

%files
%doc README.md examples
%license LICENSE
%{_bindir}/tx