# Generated by rust2rpm 27
%bcond check 1

%global crate typstyle

Name:           rust-typstyle
Version:        0.14.4
Release:        1%?dist
Summary:        CLI for Typstyle

License:        Apache-2.0
URL:            https://crates.io/crates/typstyle
Source:         %{crates_source}
Source1:        https://raw.githubusercontent.com/typstyle-rs/typstyle/v%{version}/LICENSE
Packager:       metcya <metcya@gmail.com>

BuildRequires:  anda-srpm-macros rust-packaging >= 24 mold

%global _description %{expand:
The CLI for Typstyle.}

%description %{_description}

%package     -n %{crate}
Summary:        %{summary}
License:        Apache-2.0

%description -n %{crate} %{_description}

%files       -n %{crate}
%license LICENSE
%license LICENSE.dependencies
%doc README.md
%{_bindir}/typstyle

%pkg_completion -Bzfn %{crate}

%prep
%autosetup -n %{crate}-%{version} -p1
cp %{S:1} LICENSE
%cargo_prep_online

%build
%{cargo_license_summary_online}
%{cargo_license_online} > LICENSE.dependencies
%cargo_build
mkdir -p completions
for shell in bash zsh fish; do
    target/rpm/%{crate} completions $shell > completions/%{crate}-completion.$shell
done

%install
%crate_install_bin
install -Dm644 "completions/%{crate}-completion.bash" "%{buildroot}/%{bash_completions_dir}/%{crate}"
install -Dm644 "completions/%{crate}-completion.zsh" "%{buildroot}/%{zsh_completions_dir}/_%{crate}"
install -Dm644 "completions/%{crate}-completion.fish" "%{buildroot}/%{fish_completions_dir}/%{crate}.fish"

%if %{with check}
%check
%cargo_test
%endif

%changelog
%autochangelog
