#! /usr/bin/bash
# IMPORTANT -- LEGAL NOTICE!

#     gignore: a .gitignore manipulation program
#    Copyright (C) 2026  Asher Mullaney \<asher.mullaney@gmail.com\>
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <https://www.gnu.org/licenses/>.



echo -e "Checking for Rustup toolchains..."
stat /home/$USER/.rustup/toolchains > /dev/null 2> /dev/null
if [ $? -ne 0 ]; then
    echo -e "\nEnsure Rustup toolchains are installed."
    exit 1
fi
echo -e "Yes."
echo -e "\nChecking if Cargo works..."
cargo --version > /dev/null 2> /dev/null
if [ $? -ne 0 ]; then
    echo -e "\nEnsure Cargo is correctly installed and ready to go."
    exit 1
fi
echo -e "
# IMPORTANT -- LEGAL NOTICE!

#     gignore: a .gitignore manipulation program
#    Copyright (C) 2026  Asher Mullaney \<asher.mullaney@gmail.com\>
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <https://www.gnu.org/licenses/>.
" > Makefile

echo  -e "\nGood to go!"
echo "
make:
	cargo b --release
	echo '\n\ninstall:\n	chmod 755 target/release/gignore\n	chown -f root:root target/release/gignore\n	cp target/release/gignore /usr/bin/\n	mkdir /usr/lib/gignore\n	touch /usr/lib/gignore/gignore_templates\n	cp gignore_man.1 /usr/share/man/man1/gignore.1' >> Makefile

" >> Makefile


