#!/usr/bin/env python
"""
Convenience script so that you don't need to install before use.

Copyright 2019 Markus Wallerberger.
Released under the GNU Lesser General Public License, Version 3 only.
See LICENSE.txt for permissions on usage, modification and distribution
"""
from __future__ import print_function
import os.path
import pkgutil
import sys
import textwrap

INSTALLED_NOTE = textwrap.dedent("""\
    NOTE: fsource is already installed, but we will use the packages from
          the current directory.  If this is not what you want, run `fsource`
          instead of this binary (`bin/fsource`).

    """)

if __name__ == '__main__':
    if pkgutil.find_loader("fsource"):
        sys.stderr.write(INSTALLED_NOTE)
    HEREPATH = os.path.dirname(os.path.realpath(__file__))
    srcdir = os.path.join(HEREPATH, os.pardir, "src")
    sys.path.insert(0, srcdir)
    from fsource._cli import main
    main()
