
    Ih	                     X    d Z ddlZddlZddlZddlZd Z G d dej                        Zy)z#
Core components for click_plugins
    Nc                       fd}|S )ap  
    A decorator to register external CLI commands to an instance of
    `click.Group()`.

    Parameters
    ----------
    plugins : iter
        An iterable producing one `pkg_resources.EntryPoint()` per iteration.
    attrs : **kwargs, optional
        Additional keyword arguments for instantiating `click.Group()`.

    Returns
    -------
    click.Group()
    c                    t        | t        j                        st        d      xs dD ]"  }	 | j	                  |j                                $ | S # t        $ r' | j	                  t        |j                               Y Vw xY w)Nz<Plugins can only be attached to an instance of click.Group() )	
isinstanceclickGroup	TypeErroradd_commandload	ExceptionBrokenCommandname)groupentry_pointpluginss     K/var/www/html/planif/env/lib/python3.12/site-packages/click_plugins/core.py	decoratorzwith_plugins.<locals>.decorator   s    %-Z[["=b 	CKC!!+"2"2"45	C   C !!-0@0@"AB	Cs   A-BBr   )r   r   s   ` r   with_pluginsr      s    $     c                   "    e Zd ZdZd Zd Zd Zy)r   a^  
    Rather than completely crash the CLI when a broken plugin is loaded, this
    class provides a modified help message informing the user that the plugin is
    broken and they should contact the owner.  If the user executes the plugin
    or specifies `--help` a traceback is reported showing the exception the
    plugin loader encountered.
    c                    t         j                  j                  | |       t        j                  j                  t        j                  xr t        j                  d   xs t              }t        j                  j                  d      rd}nd}dt        j                         z   | _        |d|d| j                  dz   | _        y	)
z[
        Define the special help messages after instantiating a `click.Command()`.
        r   CLICK_PLUGINS_HONESTLYu   💩u   †zK
Warning: entry point could not be loaded. Contact its author for help.


z& Warning: could not load plugin. See ` z	 --help`.N)r   Command__init__ospathbasenamesysargv__file__environget	traceback
format_exchelpr   
short_help)selfr   	util_nameicons       r   r   zBrokenCommand.__init__;   s     	tT*GG$$SXX%=#((1+%IJ	::>>23 DD+""$% 		
 $))% % 	r   c                 |    t        j                  | j                  |j                         |j	                  d       y)z?
        Print the traceback instead of doing nothing.
        )color   N)r   echor&   r,   exit)r(   ctxs     r   invokezBrokenCommand.invokeR   s%     	

499CII.r   c                     |S )Nr   )r(   r0   argss      r   
parse_argszBrokenCommand.parse_args[   s    r   N)__name__
__module____qualname____doc__r   r1   r4   r   r   r   r   r   1   s    &.r   r   )r8   r   r   r   r$   r   r   r   r   r   r   <module>r9      s.   
  	 
 !H+EMM +r   