# Path: py_mina/cli/templates.py
# def generate_staged_templates():
# 
# Path: py_mina/echo.py
# def cli_staged_init_warning(default_directory = 'deploy'):
#     notifictaion = red('\n[WARNING]\n\nDon\'t forget to specify %s %s' % (white('deployfile FILEPATH (-f)'), red('when running staged deployment')))
#     prod_path = white('-f %s' % os.path.join(default_directory, 'production.py'))
#     dev_path = white('-f %s' % os.path.join(default_directory, 'dev.py'))
# 
#     staged_deploy_notification = '''{0}
# 
# Production:
#     $ py_mina {1} run setup
#     $ py_mina {1} run deploy
# 
# Dev:
#     $ py_mina {2} run setup
#     $ py_mina {2} run deploy'''.format(notifictaion, prod_path, dev_path)
# 
#     print(staged_deploy_notification)


import os
import time
from fabric.main import load_fabfile
from fabric.tasks import execute
from fabric.colors import green, red, yellow
from fabric.contrib.console import confirm
from py_mina.cli.templates import base_template, generate_staged_templates
from py_mina.echo import cli_staged_init_warning
            print(green('Created backup file %s' % yellow(backup_fullpath)))

          create_file(filepath, content)

      except Exception as error: 
        print(red(error))


  def create_file(filepath, content):
    """
    Writes content to file
    """

    fullpath = os.path.join(os.path.realpath(os.curdir), filepath)

    try:
      with open(filepath, 'w') as f: f.write(content)
      print(green('Deployfile successfully created in %s' % yellow(fullpath)))
    except Exception as error: 
      print(red(error))


  backup_happened = False
  staged = args.get('staged')
  backup_timestamp = time.time()

  if staged == False:
    create_or_backup(args.get('filename'), base_template, backup_timestamp)
  else:
    default_directory = 'deploy/' if staged == None else staged

# Path: py_mina/cli/templates.py
# def generate_staged_templates():
# 
# Path: py_mina/echo.py
# def cli_staged_init_warning(default_directory = 'deploy'):
#     notifictaion = red('\n[WARNING]\n\nDon\'t forget to specify %s %s' % (white('deployfile FILEPATH (-f)'), red('when running staged deployment')))
#     prod_path = white('-f %s' % os.path.join(default_directory, 'production.py'))
#     dev_path = white('-f %s' % os.path.join(default_directory, 'dev.py'))
# 
#     staged_deploy_notification = '''{0}
# 
# Production:
#     $ py_mina {1} run setup
#     $ py_mina {1} run deploy
# 
# Dev:
#     $ py_mina {2} run setup
#     $ py_mina {2} run deploy'''.format(notifictaion, prod_path, dev_path)
# 
#     print(staged_deploy_notification)


# Path: py_mina/cli/commands.py
import os
import time
from fabric.main import load_fabfile
from fabric.tasks import execute
from fabric.colors import green, red, yellow
from fabric.contrib.console import confirm
from py_mina.cli.templates import base_template, generate_staged_templates
from py_mina.echo import cli_staged_init_warning

            print(green('Created backup file %s' % yellow(backup_fullpath)))

          create_file(filepath, content)

      except Exception as error: 
        print(red(error))


  def create_file(filepath, content):
    """
    Writes content to file
    """

    fullpath = os.path.join(os.path.realpath(os.curdir), filepath)

    try:
      with open(filepath, 'w') as f: f.write(content)
      print(green('Deployfile successfully created in %s' % yellow(fullpath)))
    except Exception as error: 
      print(red(error))


  backup_happened = False
  staged = args.get('staged')
  backup_timestamp = time.time()

  if staged == False:
    create_or_backup(args.get('filename'), base_template, backup_timestamp)
  else:
    default_directory = 'deploy/' if staged == None else staged

    templates_files = generate_staged_templates()