a
    Lb                     @   s  d Z ddlZddl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dlmZmZmZmZmZmZmZmZ dd Zd	d
 Zejeddgddejedde dedejddedejddddejddddejdddejd d!dd"d#d$ejd%dd&dejd'd(dd)dejd*d+dd,d#d$ejd-d.d/e d0d1ejd2e dd3d4ejd5dd6dejd7e dd8d4d9d: Zed;kre  dS )<zMain `cookiecutter` CLI.    N)__version__)configure_logger)cookiecutter)OutputDirExistsExceptionInvalidModeExceptionFailedHookExceptionUndefinedVariableInTemplateUnknownExtensionInvalidZipRepositoryRepositoryNotFoundRepositoryCloneFailedc                  C   s:   t jdd } tjtjtjt}d}||| S )zAReturn the Cookiecutter version, location and Python powering it.N   z,Cookiecutter %(version)s from {} (Python {}))sysversionospathdirnameabspath__file__format)Zpython_versionlocationmessage r   /lib/python3.9/site-packages/cookiecutter/cli.pyversion_msg   s    r   c                 C   s:   |D ]}d|vrt d|qtdd |D p8dS )zValidate extra context.=zVEXTRA_CONTEXT should contain items of the form key=value; '{}' doesn't match that formc                 s   s   | ]}| d dV  qdS )r      N)split).0sr   r   r   	<genexpr>.       z)validate_extra_context.<locals>.<genexpr>N)clickZBadParameterr   collectionsOrderedDict)ctxZparamvaluer   r   r   r   validate_extra_context#   s    r'   z-hz--help)Zhelp_option_names)Zcontext_settingsz-Vz	--version)r   templateextra_context)nargscallbackz
--no-inputTzHDo not prompt for parameters and only use cookiecutter.json file content)is_flaghelpz-cz
--checkoutz1branch, tag or commit to checkout after git clone)r.   z--directoryzlDirectory within repo that holds cookiecutter.json file for advanced repositories with multi templates in itz-vz	--verbosezPrint debug informationF)r-   r.   defaultz--replayzHDo not prompt for parameters and only use information entered previouslyz-fz--overwrite-if-existszCOverwrite the contents of the output directory if it already existsz-sz--skip-if-file-existszESkip the files in the corresponding directories if they already existz-oz--output-dir.z.Where to output the generated project dir into)r/   typer.   z--config-filezUser configuration file)r1   r/   r.   z--default-configz3Do not load a config file. Use the defaults insteadz--debug-filez-File to be used as a stream for DEBUG loggingc                 C   s&  | dkr$t t    td t|r.dnd|
d z,t| ||||||||	tj	
d||d W n tttttttfy } z t | td W Y d	}~nd	}~0  ty  } z^t d
|j t d|jj tj|jddd}t d| td W Y d	}~n
d	}~0 0 d	S )a  Create a project from a Cookiecutter project template (TEMPLATE).

    Cookiecutter is free and open source software, developed and managed by
    volunteers. If you would like to help out or fund the project, please get
    in touch at https://github.com/audreyr/cookiecutter.
    r.   r   DEBUGINFO)Zstream_level
debug_fileZCOOKIECUTTER_REPO_PASSWORD)	r)   replayoverwrite_if_exists
output_dirconfig_filedefault_configpassword	directoryskip_if_file_existsr   Nz{}zError message: {}   T)indentZ	sort_keyszContext: {})r"   ZechoZget_current_contextZget_helpr   exitr   r   r   environgetr   r   r   r	   r
   r   r   r   r   r   errorjsondumpscontext)r(   r)   Zno_inputZcheckoutverboser5   r6   r7   r8   r9   r4   r;   r<   eZundefined_errZcontext_strr   r   r   main1   sH    T


	
rH   __main__)__doc__r   r   rC   r#   r"   r   r   Zcookiecutter.logr   Zcookiecutter.mainZcookiecutter.exceptionsr   r   r   r   r	   r
   r   r   r   r'   ZcommanddictZversion_optionargumentoptionPathrH   __name__r   r   r   r   <module>   s   (
&@
