# -*- coding: utf-8 -*-
'''Management commands.'''

import os
from flask.ext.script import Manager
from killtheyak.main import app, freezer

manager = Manager(app)


@manager.command
def install():
    '''Installs all required packages.'''
    os.system('pip install -U -r requirements.txt')


@manager.command
def coffee(watch=False):
    '''Compiles Coffeescript files.

    To do a one-time compile, run:
        >> ./manage.py coffee

    Enters watch mode when you run:
        >> ./manage.py coffee -w
    '''
    JAVASCRIPT_DIR = app.config['JAVASCRIPT_DIR']
    COFFEE_DIR = app.config['COFFEE_DIR']
    base_command = 'coffee -o {} '.format(JAVASCRIPT_DIR)
    coffee_files = "{}/*.coffee".format(COFFEE_DIR)
    if watch:
        print("Watching .coffee files in {} to {}"
                        .format(COFFEE_DIR, JAVASCRIPT_DIR))
        command = base_command + '-cw ' + coffee_files
    else:
        print("Compiling .coffee files in {} and compiling them to {}"
                        .format(COFFEE_DIR, JAVASCRIPT_DIR))
        command = base_command + '-c ' + coffee_files
    os.system(command)


@manager.command
def build():
    '''Builds the static files.'''
    coffee()  # Compile coffeescript
    print("Freezing it up! Brr...")
    freezer.freeze()  # Freezes the project to build/


@manager.command
def deploy():
    '''Deploys the site.'''
    build()
    os.system('git commit -am "Update pages"')
    print('Pushing to GitHub...')
    os.system('git push origin master')
    print('...done.')


@manager.command
def test(unit=True, webtest=True):
    """Runs the tests.
    """
    command = 'nosetests killtheyak/test/ --verbosity=2'
    if not unit:
        command += ' --exclude="unit_tests'
    if not webtest:
        command += ' --exclude="webtest_tests"'
    os.system(command)


if __name__ == '__main__':
    manager.run()

@@ -513,30 +513,30 @@
 '''%0A    
-JAVASCRIPT_DIR
+javascript_dir
  = app.c
@@ -563,26 +563,26 @@
 R'%5D%0A    
-COFFEE_DIR
+coffee_dir
  = app.c
@@ -643,30 +643,30 @@
 .format(
-JAVASCRIPT_DIR
+javascript_dir
 )%0A    co
@@ -699,26 +699,26 @@
 .format(
-COFFEE_DIR
+coffee_dir
 )%0A    if
@@ -812,34 +812,34 @@
 mat(
-COFFEE_DIR, JAVASCRIPT_DIR
+coffee_dir, javascript_dir
 ))%0A 
@@ -1009,34 +1009,34 @@
 mat(
-COFFEE_DIR, JAVASCRIPT_DIR
+coffee_dir, javascript_dir
 ))%0A 
@@ -1378,16 +1378,16 @@
 build()%0A
-
     os.s
@@ -1409,16 +1409,25 @@
 it -am %22
+%5Bdeploy%5D 
 Update p

Prepend automatic commit messages; lowercase variables