#!/usr/bin/env python3

#
# Copyright 2014 Facundo Batista, Nicolás Demarchi
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 3, as published
# by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranties of
# MERCHANTABILITY, SATISFACTORY QUALITY, 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 <http://www.gnu.org/licenses/>.
#
# For further info, check  https://github.com/PyAr/fades

"""Script to run the 'fades' utility."""

import os
import sys

# small hack to allow fades to be run directly from the project, using code
# from project itself, not anything already installed in the system
parent_dir = os.path.dirname(os.path.dirname(os.path.realpath(sys.argv[0])))
if os.path.basename(parent_dir).startswith('fades'):
    # inside the project or an opened tarball!!
    sys.path.insert(0, parent_dir)

from fades import main, FadesError  # noqa (imports after fixing the path, not at the top)

try:
    rc = main.go()
except FadesError:
    sys.exit(-1)

sys.exit(rc)
