# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function

import click
import sys

import os

from polyaxon_client.exceptions import PolyaxonHTTPError
from polyaxon_schemas.polyaxonfile.polyaxonfile import PolyaxonFile

from polyaxon_cli.cli.project import get_project_or_local, equal_projects
from polyaxon_cli.managers.ignore import IgnoreManager
from polyaxon_cli.managers.project import ProjectManager
from polyaxon_cli.utils import constants
from polyaxon_cli.utils.clients import PolyaxonClients
from polyaxon_cli.utils.files import create_init_file
from polyaxon_cli.utils.formatting import Printer


@click.command()
@click.argument('project', type=str)
@click.option('--run', is_flag=True, default=True,
              help='Init a polyaxon file with `exec` step template.')
@click.option('--model', is_flag=True, default=False,
              help='Init a polyaxon file with `model` step template.')
def init(project, run, model):
    """Init a new polyaxonfile specification."""
    user, project_name = get_project_or_local(project)
    try:
        project_config = PolyaxonClients().project.get_project(user, project_name)
    except PolyaxonHTTPError:
        Printer.print_error('Make sure you have a project with this name `{}`'.format(project))
        Printer.print_error('You can a new project with this command: '
                            'polyaxon project create --name={} --description=...'.format(project))
        sys.exit(1)

    if not any([model, run]) and not all([model, run]):
        Printer.print_error("You must specify which an init option, "
                            "possible values: `--model` or `--run`.")
        sys.exit(1)

    result = False
    if model:
        result = create_init_file(constants.INIT_FILE_MODEL, project)

    elif run:
        result = create_init_file(constants.INIT_FILE_RUN, project)

    if result:
        ProjectManager.set_config(project_config, init=True)
        IgnoreManager.init_config()
        Printer.print_success(
            "Project `{}` was initialized and Polyaxonfile was created successfully `{}`".format(
                project, constants.INIT_FILE))
        sys.exit(1)

    # if we are here the file was not created
    if not os.path.isfile(constants.INIT_FILE):
        Printer.print_error(
            "Something went wrong, init command did not create a file.\n"
            "Possible reasons: you don't have the write to create the file.")
        sys.exit(1)

    # file was already there, let's check if the project passed correspond to this file
    spec = PolyaxonFile.read(constants.INIT_FILE)
    if not equal_projects(spec.project.name, project_config.unique_name):
        Printer.print_error(
            "Something went wrong, init command did not create a file.\n"
            "Anothor file already exist with different "
            "project name `{}`.".format(spec.project.name))
        sys.exit(1)

    # At this point we check if we need to re init configurations
    ProjectManager.set_config(project_config, init=True)
    IgnoreManager.init_config()
    Printer.print_success(
        "Project `{}` was initialized and Polyaxonfile was created successfully `{}`".format(
            project, constants.INIT_FILE))

@@ -737,17 +737,36 @@
 lt=True,
+ show_default=True,
 %0A
-
         
@@ -880,16 +880,35 @@
 t=False,
+ show_default=True,
 %0A       
@@ -1002,16 +1002,16 @@
 model):%0A
-
     %22%22%22I
@@ -1013,16 +1013,22 @@
  %22%22%22Init
+ialize
  a new p

Update config docs