o
    NK&h                     @   s<   d Z dZddlZddlmZ ddlmZ G dd deZdS )z#Console script for deep_translator.z"Copyright (C) 2020 Nidhal Baccouri    N)Optional)__engines__c                   @   sV   e Zd ZeZdZddee fddZdddZ	ddd	Z
dejfd
dZdddZdS )CLINcustom_argsc                 C   sb   || _ |  | _| j| jjd }|s$td| jj dt| j  || jj	| jj
d| _d S )NzTranslator z) is not supported.Supported translators: )sourcetarget)r   
parse_argsargstranslators_dictget
translator	Exceptionlistkeysr   r   )selfr   translator_class r   F/var/www/html/venv/lib/python3.10/site-packages/deep_translator/cli.py__init__   s   
zCLI.__init__returnc                 C   sF   | j | jj}td| jj d| jj  td td|  dS )zp
        function used to provide translations from the parsed terminal arguments
        @return: None
        zTranslation from z to z2--------------------------------------------------zTranslation result: N)r   	translater	   textprintr   r   )r   resr   r   r   r      s   zCLI.translatec                 C   s.   | j jdd}td| jj  d t| dS )z
        function used to return the languages supported by the translator service
        from the parsed terminal arguments
        @return: None
        T)as_dictzLanguages supported by 'z' are :
N)r   get_supported_languagesr   r	   )r   translator_supported_languagesr   r   r   r   (   s   zCLI.get_supported_languagesc                 C   s   t jdddd}|jdddtdd	 |jd
ddtdd	 |jddtdd |jddtdd |jddddd | jrB|| j}|S | }|S )z
        function responsible for parsing terminal arguments and provide
        them for further use in the translation process
        Tz Official CLI for deep-translatorz	dt --help)add_helpdescriptionusagez--translatorz-transgooglez&name of the translator you want to use)defaulttypehelpz--sourcez-srcautoz!source language to translate fromz--targetz-tgztarget language to translate to)r"   r#   z--textz-txtztext you want to translatez--languagesz-lang
store_truezpall the languages available with the translatorRun the command deep_translator -trans <translator service> -lang)actionr#   )argparseArgumentParseradd_argumentstrr   r   )r   parserparsed_argsr   r   r   r   5   sL   	zCLI.parse_argsc                 C   s    | j jr
|   d S |   d S N)r	   	languagesr   r   )r   r   r   r   runb   s   zCLI.runr-   )r   N)__name__
__module____qualname__r   r
   r   r   r   r   r   r   r'   	Namespacer   r/   r   r   r   r   r      s    


-r   )	__doc____copyright__r'   typingr   deep_translator.enginesr   objectr   r   r   r   r   <module>   s    