
    ce                         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 Zd ZdS )zCCommands related to the 'commands' section of anaconda-project.yml.    )absolute_importprint_functionN)load_project)project_ops)console_utilsc                    t          j                    sd S t          j                    dk    rd}nd}d|dd}	 t          j        d                    |                     }|                                                                }t          |          d	k    s
|d	         |vr=t          d
           t          d           t          d           t          d           ||         S )NWindowswindowsunix	bokeh_appnotebook)bcnTz6Is `{}` a (B)okeh app, (N)otebook, or (C)ommand line? r   zPlease enter 'b', 'n', or 'c'.zP    A Bokeh app is the project-relative path to a Bokeh script or app directory.zB    A notebook file is the project-relative path to a .ipynb file.zG    A command line is any command you might type at the command prompt.)
r   stdin_is_interactiveplatformsystemconsole_inputformatlowerstriplenprint)commandotherchoicesdatas       Nlib/python3.11/site-packages/anaconda_project/internal/cli/command_commands.py_ask_commandr      s    -// tI% e*==G*+c+j+jkr+s+sttzz||!!##t99> 	T!WG3 	2333deeeVWWW[\\\t}    c                    t          |           }t          j                            |j        |          }|6|                    d          r!t          j                            |          rd}||dk    rt          |          }|t          dt          j
                   dS t          j        ||||||          }|st          j        |           dS t          d|d	|d
           dS )zMAdd command to anaconda-project.yml.

    Returns:
        int exit code
    Nz.ipynbr   askz.Specify the --type option to add this command.)file   zAdded a command 'z4' to the project. Run it with `anaconda-project run z`.r   )r   ospathjoindirectory_pathendswithisfiler   r   sysstderrr   add_commandr   print_status_errors)	project_dirnamecommand_typer   env_spec_namesupports_http_optionsprojectcommand_as_filenamestatuss	            r   r-   r-   ,   s    ;''G',,w'=wGG " 0 0 : : "rw~~Na?b?b "! *|u4 *#D)) >SZPPPPq$WdL'=ZoppF )&111q_c_c_ceieieijkkkqr    c                     t          |           }t          j        ||          }|st          j        |           dS t          d                    |                     dS )zKRemove a command from the project.

    Returns:
        int exit code
    r$   z*Removed the command '{}' from the project.r   )r   r   remove_commandr   r.   r   r   )r/   r0   r4   r6   s       r   r8   r8   I   sc     ;''G'66F )&111q:AA$GGHHHqr    c                 >   t          |           }t          j        |          rdS |j        rNt	          d                    |                      t          j        |j                                                   n"t	          d                    |                      dS )zJList the commands on the project.

    Returns:
        int exit code
    r$   zCommands for project: {}
"No commands found for project: {}
r   )r   r   print_project_problemscommandsr   r   print_names_and_descriptionsvaluesr/   r4   s     r   list_commandsr@   Z   s     ;''G+G44 q I*11+>>???273C3J3J3L3LMMMM3::;GGHHH1r    c                     t          |           }t          j        |          rdS |j        rt	          |j        j                   n"t	          d                    |                      dS )zVList only the default command on the project.

    Returns:
        int exit code
    r$   r:   r   )r   r   r;   r<   r   default_commandr0   r   r?   s     r   list_default_commandrC   l   sp     ;''G+G44 q I 	g%*++++3::;GGHHH1r    c                 f    t          | j        | j        | j        | j        | j        | j                  S )z7Submit the add command with args and returns exit code.)r-   	directoryr0   typer   env_specr3   argss    r   mainrJ      s(    t~ty$)T\4=Z^Ztuuur    c                 6    t          | j        | j                  S )z:Submit the remove command with args and returns exit code.)r8   rE   r0   rH   s    r   main_removerL      s    $.$)444r    c                 *    t          | j                  S )z6Start the list command with args and return exit code.)r@   rE   rH   s    r   	main_listrN      s    (((r    c                 *    t          | j                  S )z>Start the list default command with args and return exit code.)rC   rE   rH   s    r   main_defaultrP      s    ///r    )__doc__
__future__r   r   r%   r   r+   *anaconda_project.internal.cli.project_loadr   anaconda_projectr   anaconda_project.internal.clir   r   r-   r8   r@   rC   rJ   rL   rN   rP    r    r   <module>rW      s   J I 6 6 6 6 6 6 6 6 				  



 C C C C C C ( ( ( ( ( ( 7 7 7 7 7 7  0  :  "  $  &v v v
5 5 5
) ) )
0 0 0 0 0r    