a
    õ£BeR  ã                   @   s.   d dl Z G dd„ deƒZG dd„ de jƒZdS )é    Nc                   @   s   e Zd ZdS )Ú_BailoutN)Ú__name__Ú
__module__Ú__qualname__© r   r   úS/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/json5/arg_parser.pyr      s   r   c                       sX   e Zd ZejZ‡ fdd„Zd‡ fdd„	Zddd„Zddd	„Zddd„Z	ddd„Z
‡  ZS )ÚArgumentParserc                    sR   ||d< ||d< t j|d< tt| ƒjf i |¤Ž || _d | _| jddddd� d S )	NÚprogÚdescriptionÚformatter_classz-Vz	--versionÚ
store_truezprint the version and exit)ÚactionÚhelp)ÚargparseÚRawDescriptionHelpFormatterÚsuperr   Ú__init__Ú_hostÚexit_statusÚadd_argument)ÚselfÚhostr	   ÚdescÚkwargs©Ú	__class__r   r   r      s    

ÿzArgumentParser.__init__Nc                    s2   zt t| ƒj||d�}W n ty,   Y d S 0 |S )N)ÚargsÚ	namespace)r   r   Ú
parse_argsr   )r   r   r   Úrargsr   r   r   r   #   s    ÿ
zArgumentParser.parse_argsc                 C   s   | j j||dd� d S )NÚ
)ÚmsgÚstreamÚend)r   Úprint_)r   r!   Úfiler   r   r   Ú_print_message.   s    zArgumentParser._print_messagec                 C   s   | j |  ¡ |d� d S )N)r!   r%   )r&   Úformat_help)r   r%   r   r   r   Ú
print_help1   s    zArgumentParser.print_helpTc                 C   s   | j dd| j|f |d� d S )Né   z%s: error: %s
)Úbailout)Úexitr	   )r   Úmessager*   r   r   r   Úerror4   s    zArgumentParser.errorr   c                 C   s*   || _ |r| j|| jjd� |r&tƒ ‚d S )N)r%   )r   r&   r   Ústderrr   )r   Ústatusr,   r*   r   r   r   r+   7   s
    zArgumentParser.exit)NN)N)N)T)r   NT)r   r   r   r   ÚSUPPRESSr   r   r&   r(   r-   r+   Ú__classcell__r   r   r   r   r      s   



  ÿr   )r   Ú	Exceptionr   r   r   r   r   r   Ú<module>   s   