
    :)diW                    f   U d dl mZ d dlZd dlZd dlZd dlZd dlmZmZm	Z	m
Z
mZmZmZmZmZmZmZmZmZmZmZmZ d dlZd dlmZmZmZ d dlmZ d dlmZ d dlm Z  d dl!m"Z" erd d	l#m$Z$ d d
l%m&Z& d dl'm(Z(m)Z) dZ*de+d<    G d de          Z, G d de,e          Z-e-Z. G d dee-          Z/ddZ0dS )     )annotationsN)TYPE_CHECKINGAnyCallableDictIterableListLiteralMappingNoReturnOptionalSequenceTextIOTypeUnioncastoverload)CommandCommandCollectionGroup)PacifyFlushWrapper)RichContext)RichHelpConfiguration)RichHelpFormatter)Console)RichPanelRow)RichCommandPanel	RichPanelFboolOVERRIDES_GUARDc                  ,    e Zd ZU dZeZded<   dZded<   dddddA fdZe	dBd            Z
dC fdZe	dDd            ZdEdZdFdZe	 	 	 	 dGdHd)            Ze	 	 	 	 dIdJd,            Z	 	 	 	 	 dKdLd0ZdMd3ZdMd4ZdNd6ZdMd7ZdOd9Z	 dPdQd>ZdRd@Z xZS )SRichCommandz
    Richly formatted click Command.

    Inherits click.Command and overrides help and error methods
    to print richly formatted output.

    This class can be used as a mixin for other click command objects.
    zType[RichContext]context_classNzOptional[RichHelpFormatter]
_formatter)aliasespanelspanelargsr   r%   Optional[Iterable[str]]r&   %Optional[List['RichPanel[Any, Any]']]r'   Optional[Union[str, List[str]]]kwargsreturnNonec                    t                      j        |i | || _        |pg | _        |pg | _        t          | d          s	d| _        dS dS )zCreate Rich Command instance._help_optionN)super__init__r'   r&   r%   hasattrr0   )selfr%   r&   r'   r(   r,   	__class__s         ^/var/www/menimich/repos/protonApp/venv/lib/python3.11/site-packages/rich_click/rich_command.pyr2   zRichCommand.__init__@   sh     	$)&)))
39<R&-mt^,, 	% $D	% 	%    Optional['Console']c                n    t          j        dt          d           | j                            d          S )z
        Rich Console.

        This is a separate instance from the help formatter that allows full control of the
        console configuration.

        See `rich_config` decorator for how to apply the settings.
        zRRichCommand.console is deprecated. Please use the click.Context's console instead.   
stacklevelrich_console)warningswarnDeprecationWarningcontext_settingsget)r4   s    r6   consolezRichCommand.consoleP   s?     	`	
 	
 	
 	

 $((888r7   ctxclick.ContextDict[str, Any]c                    t                                                    }fd| j        D             |d<   | j        t	          | j                  nd |d<   |S )Nc                :    g | ]}|                               S  )to_info_dict).0prD   s     r6   
<listcomp>z,RichCommand.to_info_dict.<locals>.<listcomp>c   s%    CCC!!..--CCCr7   r&   r%   )r1   rJ   r&   r%   list)r4   rD   infor5   s    ` r6   rJ   zRichCommand.to_info_dicta   s^    ww##C((CCCCt{CCCX040H$t|,,,dYr7   Optional[RichHelpConfiguration]c                    t          j        dt          d           | j                            d          }t          |t                    rt          di |S |S )zRich Help Configuration.zZRichCommand.help_config is deprecated. Please use the click.Context's help config instead.r:   r;   rich_help_configrI   )r>   r?   r@   rA   rB   
isinstancer   r   )r4   cfgs     r6   help_configzRichCommand.help_configg   sj     	h	
 	
 	
 	
 #''(:;;c7## 	0(//3///
r7   r   c                f   | j                             di           }	 t          |t                    rt	          j        di |S t          |t                    r|S nJ# t          $ r=}t          j        |j	        j
         |j         t          j                   Y d}~nd}~ww xY wt	                      S )z
        Use for error handling when a Context is not available.

        If the Context is available, then the help configuration in the Context
        should be preferred.
        rR   fileNrI   )rA   rB   rS   r   r   load_from_globals	Exceptionclickechor5   __name__r(   sysstderr)r4   rT   es      r6   _generate_rich_help_configz&RichCommand._generate_rich_help_configu   s     #''(:B??	K#w'' ,>EEEEEC!677 
 	K 	K 	KJ!+.888szJJJJJJJJJ	K$&&&s   %A A 
B"%3BB"r   c                     ddl m} d fd}	  |            }t          |t                    s |            }n1|                    d          }n# t
          $ r  |            }Y nw xY w|S )	Nr   )get_current_contextr-   r   c                                                      } j                            | j        j        rj        j        nd           }|S )N)configexport_console_as)ra   r#   formatter_classerrors_in_output_formatrf   )re   	formatterr4   s     r6   _get_formatterz4RichCommand._error_formatter.<locals>._get_formatter   sV    4466F*::<@<N<fpD&88lp ;  I r7   T)
error_moder-   r   )r[   rc   rS   r   make_formatterRuntimeError)r4   rc   rj   rD   ri   s   `    r6   _error_formatterzRichCommand._error_formatter   s    ------	 	 	 	 	 		@2244C c;// @*N,,		..$.??		  	) 	) 	)&((III	) s   
A A'&A'TSequence[str] | None	prog_name
str | Nonecomplete_varstandalone_modeLiteral[True]extrar   c                    d S NrI   r4   r(   rq   rs   rt   rv   s         r6   mainzRichCommand.main   s	     3r7   .r   c                    d S rx   rI   ry   s         r6   rz   zRichCommand.main   s	     cr7   Optional[Sequence[str]]Optional[str]windows_expand_argsc                   |8t           j        dd          }t          j        dk    r|rddlm}  ||          }nt          |          }t          r|J |ddlm}  |            }| 	                    |||           d }		 	  | j
        ||fi |5 }	|                     |	          }
|s|
cd d d            S |	                                 d d d            n# 1 swxY w Y   d S d S # t          t          f$ r? t          j        t           j                   t          j                                        d t          j        j        $ r}ddlm} |sLt/          |t          j        j                  r-t3          |j                   t          j        |j                   |s |                                 }|                    |           t3          |                                t           j        d	           t          j        |j                   Y d }~d S d }~wt>          $ r}|j         t@          j!        k    rtE          tF          tI          t           j%                            t           _%        tE          tF          tI          t           j                            t           _        t          j        d           n Y d }~d S d }~ww xY w# t          j        j&        $ r3}|rt          j        |j                   n|j        cY d }~S Y d }~d S d }~wt          j        j        $ r |s 	 |                                 }|'                                 t3          |                                t           j        d	           n0# tP          $ r# t          j        d
t           j                   Y nw xY wt          j        d           Y d S # t          j        d           w xY ww xY w)N   ntr   )_expand_args)_detect_program_namerW   )CLICK_IS_BEFORE_VERSION_82 )rX   endzAborted!))r^   argvosnameclick.utilsr   rN   r   r   _main_shell_completionmake_contextinvokeexitEOFErrorKeyboardInterruptr[   r\   r_   
exceptionsAbortClickExceptionrich_click._compat_clickr   rS   NoArgsIsHelpErrorprintmessage	exit_codero   write_errorgetvalueOSErrorerrnoEPIPEr   r   r   stdoutExitwrite_abortrZ   )r4   r(   rq   rs   rt   r~   rv   r   r   rD   rvr`   r   ri   s                 r6   rz   zRichCommand.main   s    <8ABB<Dw$#6444444#|D))::D 	$###888888,,..I 	##E9lCCC6	$&T&y$@@%@@ CS))B* "!        HHJJJ                   /0 9 9 9

++++&,,..D8#2 & & &OOOOOO1 .!!U%5%GHH .ai(((---&  1133	%%a(((i((**DDDD%%%%%%%%%   7ek))!%f.@.L.L!M!MCJ!%f.@.L.L!M!MCJHQKKKK  KKKKK	 $ 	# 	# 	# #%%%%{"""""" &%%%%% % 	 	 	"  1133	 %%'''i((**DDDDD	  8 8 8
:CJ7777778 	s   C& C*C& 7CC& CC& CC& &A"KCHK K"BJ?9K ?KK O"L	=O	O$M;8AO;*N(%O'N((O+OOOr   ri   c                    t           rt          | d||           d S |                     ||           |                     ||           |                     ||           |                     ||           d S )Nr"   r    prevent_incompatible_overridesformat_usageformat_help_textformat_optionsformat_epilogr4   rD   ri   s      r6   format_helpzRichCommand.format_help  s     	/*4YOOOOOc9---!!#y111Y///sI.....r7   c                ,    ddl m}  || ||           d S )Nr   )get_rich_help_text)rich_click.rich_help_renderingr   )r4   rD   ri   r   s       r6   r   zRichCommand.format_help_text  s/    EEEEEE4i00000r7   click.HelpFormatterc                    ddl m} ddlm}  || ||          }|D ]`}|                    | ||          }t          |j        |          rt          |j        j                  dk    r|	                    |           ad S )Nr   )Table)construct_panels)

rich.tabler   rich_click.rich_panelr   renderrS   
renderablelenrowswrite)r4   rD   ri   r   r   r&   r'   rL   s           r6   r   zRichCommand.format_options$  s    $$$$$$::::::!!$Y77 	# 	#ET3	22AalE22 #c!,:K6L6Lq6P6P"""	# 	#r7   c                ,    ddl m}  || ||           d S )Nr   )get_rich_epilog)r   r   )r4   rD   ri   r   s       r6   r   zRichCommand.format_epilog/  s.    BBBBBBc9-----r7   Union[click.Option, None]c                    |                      |          }|r| j        sdS | j        2ddlm}   || |            | j                                        | _        | j        S )z
        Return the help option object.

        Skipped if :attr:`add_help_option` is ``False``.

        .. versionchanged:: 8.1.8
            The help option is now cached to avoid creating it multiple times.
        Nr   )help_option)get_help_option_namesadd_help_optionr0   rich_click.decoratorsr   paramspop)r4   rD   help_option_namesr   s       r6   get_help_optionzRichCommand.get_help_option4  s     !66s;;  	(< 	4 $999999 ,KK*+D111 $ 1 1D  r7   'RichContext''RichHelpFormatter'Optional['RichCommandPanel']'RichPanelRow'c                *    ddl m}  || |||          S )zBCreate a row for the rich table corresponding with this parameter.r   )get_command_rich_table_row)r   r   )r4   rD   ri   r'   r   s        r6   get_rich_table_rowzRichCommand.get_rich_table_rowP  s.     	NMMMMM))$YFFFr7   'RichPanel[Any, Any]'c                :    | j                             |           dS )z#Add a RichPanel to the RichCommand.N)r&   append)r4   r'   s     r6   	add_panelzRichCommand.add_panel[  s    5!!!!!r7   )r(   r   r%   r)   r&   r*   r'   r+   r,   r   r-   r.   )r-   r8   )rD   rE   r-   rF   )r-   rP   )r-   r   rl   )NNNT)r(   rp   rq   rr   rs   rr   rt   ru   rv   r   r-   r   )NNN.)r(   rp   rq   rr   rs   rr   rt   r   rv   r   r-   r   )NNNTT)r(   r|   rq   r}   rs   r}   rt   r   r~   r   rv   r   r-   r   rD   r   ri   r   r-   r.   rD   rE   ri   r   r-   r.   )rD   rE   r-   r   rx   )rD   r   ri   r   r'   r   r-   r   )r'   r   r-   r.   )r]   
__module____qualname____doc__r   r#   __annotations__r$   r2   propertyrC   rJ   rU   ra   ro   r   rz   r   r   r   r   r   r   r   __classcell__r5   s   @r6   r"   r"   3   s:          (3M2222.2J2222
 ,08<15% % % % % % % %  9 9 9 X9          X' ' ' '"   0  &* $#')-    X  &* $#' #    X )-#'&* $$(Y Y Y Y Y|/ / / /1 1 1 1	# 	# 	# 	#. . . .
! ! ! !@ /3		G 	G 	G 	G 	G" " " " " " " "r7   r"   c                      e Zd ZU dZeZded<   eZded<   d6 fdZ	d7dZ
d8dZd9 fdZed:d            Zed;d            Zd<dZed=d            Zed>d             Zd?d"Z	 	 	 d@dAd,ZdB fd0Z	 	 	 d@dA fd1ZdCd5Z xZS )D	RichGroupz
    Richly formatted click Group.

    Inherits click.Group and overrides help and error methods
    to print richly formatted output.
    zOptional[Type[RichCommand]]command_classz(Optional[Union[Type[Group], Type[type]]]group_classr(   r   r,   r-   r.   c                (    t                      j        |i | i | _        i | _        | j        D ]a}| j        |         }t          |dd          }|r|D ]}|| j        |<   t          |dd          }|j        r|r|                     ||           bdS )zCreate RichGroup instance.r%   Nr'   )r1   r2   _alias_mapping_panel_command_mappingcommandsgetattrr   add_command_to_panel)	r4   r(   r,   r   cmdr%   aliasr'   r5   s	           r6   r2   zRichGroup.__init__k  s    $)&))).0 =?#M 
	6 
	6D-%C/6sIt/L/LG 6$ 6 6E15D'..#*3#>#>Ex 6E 6))#u555
	6 
	6r7   rD   rE   ri   r   c                    d S rx   rI   r   s      r6   format_commandszRichGroup.format_commands  s    r7   r   r   c                    t           rt          | d||           d S |                     ||           |                     ||           |                     ||           |                     ||           d S )Nr   r   r   s      r6   r   zRichGroup.format_help  s     	/*4c9MMMMMc9---!!#y111Y///sI.....r7   c                6     t                      j        |i |S )zAlias for :meth:`main`.)r1   __call__)r4   r(   r,   r5   s      r6   r   zRichGroup.__call__  s!    
  uww0000r7   _RichGroup__funcCallable[..., Any]r"   c                    d S rx   rI   r4   r   s     r6   commandzRichGroup.command  s    BE#r7   +Callable[[Callable[..., Any]], RichCommand]c                    d S rx   rI   r4   r(   r,   s      r6   r   zRichGroup.command  s    adadr7   ?Union[Callable[[Callable[..., Any]], RichCommand], RichCommand]c                    ddl m d}r:t          d                   r%t                    dk    rr
J d            \  }d                    d           j        r j        xd<   d fd}| ||          S |S )a  
        A shortcut decorator for declaring and attaching a command to
        the group. This takes the same arguments as :func:`command` and
        immediately registers the created command with this group by
        calling :meth:`add_command`.

        To customize the command class used, set the
        :attr:`command_class` attribute.

        .. versionchanged:: 8.1
            This decorator can be applied without parentheses.

        .. versionchanged:: 8.0
            Added the :attr:`command_class` attribute.
        r   )r   Nr   z7Use 'command(**kwargs)(callable)' to provide arguments.rI   clsfr   r-   r"   c                `   rBt          t                    s-                    dd           }                    dd           }n*                    d          }                    d          }  i |           }                    |                               |||           |S Nr'   r%   )r%   r'   
issubclassr"   r   rB   add_command_handle_extras_add_command)	r   r'   r%   r   r(   r   r   r,   r4   s	       r6   	decoratorz$RichGroup.command.<locals>.decorator  s     0:c;77 0

7D11 **Y55

7++ **Y//7ww777::CS!!!++C+NNNJr7   )r   r   r-   r"   )r   r   callabler   rB   r   )r4   r(   r,   funcr   r   r   s   ```  @@r6   r   zRichGroup.command  s      	211111-1 	HT!W%% 	t99>>&>>2k>>>GTD'-zz%'8'8 	5#+"&"44F5MC
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 9T??"r7   'RichGroup'c                    d S rx   rI   r   s     r6   groupzRichGroup.group  s    @Cr7   +Callable[[Callable[..., Any]], 'RichGroup']c                    d S rx   rI   r   s      r6   r  zRichGroup.group  s    _b_br7   ?Union[Callable[[Callable[..., Any]], 'RichGroup'], 'RichGroup']c                `    ddl m d}r:t          d                   r%t                    dk    rr
J d            \  }d                    d           j        1/ j        t          u rt                     xd<   n j        xd<   d fd}| ||          S |S )a  
        A shortcut decorator for declaring and attaching a group to
        the group. This takes the same arguments as :func:`group` and
        immediately registers the created group with this group by
        calling :meth:`add_command`.

        To customize the group class used, set the :attr:`group_class`
        attribute.

        .. versionchanged:: 8.1
            This decorator can be applied without parentheses.

        .. versionchanged:: 8.0
            Added the :attr:`group_class` attribute.
        r   )r  Nr   z5Use 'group(**kwargs)(callable)' to provide arguments.rI   r   r   r   r-   r   c                `   rBt          t                    s-                    dd           }                    dd           }n*                    d          }                    d          }  i |           }                    |                               |||           |S r   r   )	r   r'   r%   r   r(   r   r  r,   r4   s	       r6   r   z"RichGroup.group.<locals>.decorator  s     0:c;77 0

7D11 **Y55

7++ **Y//3UUD3F33A66CS!!!++C+NNNJr7   )r   r   r-   r   )r   r  r   r   rB   r   type)r4   r(   r,   r   r   r   r  s   ```  @@r6   r  zRichGroup.group  s     	0/////-1 	HT!W%% 	t99>>&>>2i>>>GTD8>

58I8I'CK4''&*4jj0u&*&66u
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 9T??"r7   Nr   click.Commandr   r}   r%   r)   r'   r+   c                   |p|j         }|r|D ]}|| j        |<   t          |dd          }|r|D ]}|| j        |<   | j                            |d           |pt          |dd          }|r|                     ||           dS dS )a]  
        Create backwards compatibility with add_command() subclass interfaces
        that have not migrated to rich-click's 1.9.0 add_command(...).

        This should stay in place until a 2.0 release.

        In the meanwhile, devs should get mypy errors indicating that add_command()
        does not implement all the proper kwargs.
        r%   Nr'   )r   r   r   r   r   )r4   r   r   r%   r'   _namer   additional_aliasess           r6   r   z$RichGroup._handle_extras_add_command  s      %SX 	3  3 3-2#E**$S)T:: 	3+ 3 3-2#E**t,,,4gt44 	2%%c511111	2 	2r7   cmd_namestrOptional[click.Command]c                ~    | j                             ||          }t                                          ||          S rx   )r   rB   r1   get_command)r4   rD   r  	_cmd_namer5   s       r6   r  zRichGroup.get_command  s5    '++Hh??	ww""3	222r7   c                    t                                          ||           |p|j        }|s|r|                     ||||           dS dS )z
        Register another :class:`Command` with this group. If the name
        is not provided, the name of the command is used.
        )r   r%   r'   N)r1   r   r   r   )r4   r   r   r%   r'   r
  r5   s         r6   r   zRichGroup.add_command   sl     	C&&&%SX 	Ze 	Z++CdGSX+YYYYY	Z 	Zr7   r   
panel_nameUnion[str, Iterable[str]]c                   |j         sd S | j                            |j         g            t          |t                    r'| j        |j                                      |           d S | j        |j                                      |           d S rx   )r   r   
setdefaultrS   r  r   extend)r4   r   r  s      r6   r   zRichGroup.add_command_to_panel0  s    
 | 	F#..w|R@@@j#&& 	I'5<<ZHHHHH'5<<ZHHHHHr7   )r(   r   r,   r   r-   r.   r   r   )r(   r   r,   r   r-   r   )r   r   r-   r"   )r(   r   r,   r   r-   r   )r(   r   r,   r   r-   r   )r   r   r-   r   )r(   r   r,   r   r-   r  )r(   r   r,   r   r-   r  )NNN)
r   r  r   r}   r%   r)   r'   r+   r-   r.   )rD   rE   r  r  r-   r  )r   r  r  r  r-   r.   )r]   r   r   r   r"   r   r   r  r   r2   r   r   r   r   r   r  r   r  r   r   r   r   s   @r6   r   r   `  s          2=M<<<<<@K@@@@6 6 6 6 6 6*   / / / /1 1 1 1 1 1 EEE XEddd Xd, , , ,\ CCC XCbbb Xb/ / / /h #+/152 2 2 2 2:3 3 3 3 3 3 #+/15Z Z Z Z Z Z Z I I I I I I I Ir7   r   c                      e Zd ZdZd
dZd	S )RichCommandCollectionz
    Richly formatted click CommandCollection.

    Inherits click.CommandCollection and overrides help and error methods
    to print richly formatted output.
    rD   r   ri   r   r-   r.   c                    t           rt          | d||           d S |                     ||           |                     ||           |                     ||           |                     ||           d S )Nr  r   r   s      r6   r   z!RichCommandCollection.format_helpI  s     	/*41H#yYYYYYc9---!!#y111Y///sI.....r7   Nr   )r]   r   r   r   r   rI   r7   r6   r  r  A  s2         / / / / / /r7   r  r   
class_namer  rD   r   ri   r   r-   r.   c                    ddl }ddlm} t          |j        d|           }dD ]O} || j        ||          r! t          t          |          | ||           5 t          | |          ||           PdS )zFor use by the rich-click CLI.r   N)method_is_from_subclass_of_Patched)r   r   r   r   )rich_click.patchrich_click.utilsr  r   patchr5   r"   )r   r  rD   ri   
rich_clickr  r   method_names           r6   r   r   S  s     ;;;;;;$Z%57N*7N7NOOC^ 6 6%%cmS+FF 	6-GK--c3	BBBB%GC%%c95555	6 6r7   )
r   r"   r  r  rD   r   ri   r   r-   r.   )1
__future__r   r   r   r^   r>   typingr   r   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r[   r   r   r   r   r   rich_click.rich_contextr   "rich_click.rich_help_configurationr   rich_click.rich_help_formatterr   rich.consoler   r   r   r   r   r   r    r   r"   r   RichMultiCommandr  r   rI   r7   r6   <module>r+     s   " " " " " " "  				 



                                    &  4 3 3 3 3 3 3 3 3 3 * * * * * * / / / / / / D D D D D D < < < < < <  B$$$$$$;;;;;;AAAAAAAA     j" j" j" j" j"' j" j" j"Z	[I [I [I [I [IU [I [I [I|  / / / / /-y / / /$6 6 6 6 6 6r7   