ó
źS]c           @@ sł   d  Z  d d l m Z m Z d d l Z d d l Z d d l Z d d l m Z d d l	 m
 Z
 d d l m Z d   Z d   Z d	   Z d
   Z d   Z d   Z d   Z d S(   sC   Commands related to the 'commands' section of anaconda-project.yml.i    (   t   absolute_importt   print_functionN(   t   load_project(   t   project_ops(   t   console_utilsc         C@ sÜ   t  j   s d  St j   d k r+ d } n d } i d d 6| d 6d d 6} x t r× t  j d	 j |    } | j   j	   } t
 |  d
 k sĄ | d
 | k rĎ t d  t d  t d  t d  qO n  | | SWd  S(   Nt   Windowst   windowst   unixt	   bokeh_appt   bt   ct   notebookt   ns6   Is `{}` a (B)okeh app, (N)otebook, or (C)ommand line? i    s   Please enter 'b', 'n', or 'c'.sP       A Bokeh app is the project-relative path to a Bokeh script or app directory.sB       A notebook file is the project-relative path to a .ipynb file.sG       A command line is any command you might type at the command prompt.(   R   t   stdin_is_interactivet   Nonet   platformt   systemt   Truet   console_inputt   formatt   lowert   stript   lent   print(   t   commandt   othert   choicest   data(    (    sM   lib/python2.7/site-packages/anaconda_project/internal/cli/command_commands.pyt   _ask_command   s     		"



c   	      C@ ső   t  |   } t j j | j |  } | d	 k rZ | j d  rZ t j j |  rZ d } n  | d	 k sr | d k r t |  } n  | d	 k r¤ t	 d d t
 j d St j | | | | | |  } | sŮ t j |  d St	 d | | f  d Sd	 S(
   sM   Add command to anaconda-project.yml.

    Returns:
        int exit code
    s   .ipynbR   t   asks.   Specify the --type option to add this command.t   filei   sK   Added a command '%s' to the project. Run it with `anaconda-project run %s`.i    N(   R   t   ost   patht   joint   directory_pathR   t   endswitht   isfileR   R   t   syst   stderrR   t   add_commandR   t   print_status_errors(	   t   project_dirt   namet   command_typeR   t   env_spec_namet   supports_http_optionst   projectt   command_as_filenamet   status(    (    sM   lib/python2.7/site-packages/anaconda_project/internal/cli/command_commands.pyR'   ,   s    -	c         C@ sP   t  |   } t j | |  } | s5 t j |  d St d j |   d Sd S(   sK   Remove a command from the project.

    Returns:
        int exit code
    i   s*   Removed the command '{}' from the project.i    N(   R   R   t   remove_commandR   R(   R   R   (   R)   R*   R.   R0   (    (    sM   lib/python2.7/site-packages/anaconda_project/internal/cli/command_commands.pyR1   I   s    c         C@ sk   t  |   } t j |  r d S| j rT t d j |    t j | j j    n t d j |    d S(   sJ   List the commands on the project.

    Returns:
        int exit code
    i   s   Commands for project: {}
s"   No commands found for project: {}
i    (   R   R   t   print_project_problemst   commandsR   R   t   print_names_and_descriptionst   values(   R)   R.   (    (    sM   lib/python2.7/site-packages/anaconda_project/internal/cli/command_commands.pyt   list_commandsZ   s    	c         C@ s+   t  |  j |  j |  j |  j |  j |  j  S(   s7   Submit the add command with args and returns exit code.(   R'   t	   directoryR*   t   typeR   t   env_specR-   (   t   args(    (    sM   lib/python2.7/site-packages/anaconda_project/internal/cli/command_commands.pyt   mainl   s    c         C@ s   t  |  j |  j  S(   s:   Submit the remove command with args and returns exit code.(   R1   R7   R*   (   R:   (    (    sM   lib/python2.7/site-packages/anaconda_project/internal/cli/command_commands.pyt   main_removeq   s    c         C@ s   t  |  j  S(   s6   Start the list command with args and return exit code.(   R6   R7   (   R:   (    (    sM   lib/python2.7/site-packages/anaconda_project/internal/cli/command_commands.pyt	   main_listv   s    (   t   __doc__t
   __future__R    R   R   R   R%   t*   anaconda_project.internal.cli.project_loadR   t   anaconda_projectR   t   anaconda_project.internal.cliR   R   R'   R1   R6   R;   R<   R=   (    (    (    sM   lib/python2.7/site-packages/anaconda_project/internal/cli/command_commands.pyt   <module>   s   						