#! /usr/bin/env python

import click
import logging
import os
import sys
import werkzeug  # Fixes werkzeug and PyInstaller.

def is_packaged_app():
  try:
    sys._MEIPASS
    return True
  except AttributeError:
    return False

if not is_packaged_app():
  base_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..')
  sys.path.extend([base_dir])

logging.basicConfig(level=logging.INFO, format='%(message)s')

# Fixes simplejson and PyInstaller.
import json
sys.modules['simplejson'] = json

# Fixes sys.getfilesystemencoding() and PyInstaller.
from watchdog.utils import unicode_paths
unicode_paths.fs_encoding = unicode_paths.fs_fallback_encoding

from grow import commands


@click.group()
def grow():
  """The Grow SDK: a declarative, file-based CMS for building high-quality web sites.
  See documentation at: http://growsdk.org."""


commands.add(grow)


if __name__ == '__main__':
  grow()
