
    Z[tj                        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 ddl	m
Z
 ddlmZmZmZmZ dd	lmZ dd
lmZ ddlmZ dZdeeef   fdZdej2                  dej4                  dedefdZdej2                  dej4                  dedefdZ eddedd       eddedd      fdededefdZ ededd       ededd      fdededefdZdej@                  d ee!ef   d!e!d"e!d#e!de"fd$Z#y)%    N)MutableMapping)Any   _click)shell_completion)completion_init)Shells_get_shell_nameget_completion_scriptinstall)	ParamMeta)Option)get_params_from_functionFreturnc                      t                t        j                  d      } | st        t              }nt        t
              }|j                         \  }}||fS )N,_TYPER_COMPLETE_TEST_DISABLE_SHELL_DETECTION)r	   osgetenvr   (_install_completion_placeholder_function0_install_completion_no_auto_placeholder_functionvalues)test_disable_detection
parametersinstall_param
show_params       y/home/cube/projects/richard/traning coach/task-12-independent-verification-r8/tests/profile-test-deps/typer/completion.py!get_completion_inspect_parametersr      sS    YY'UV!-.VW
-<

 !+ 1 1 3M:*$$    ctxparamvaluec                    |r| j                   r|S t        |t              rt        |      \  }}nt               \  }}t        j
                  j                  | d| d       t	        j                  d       t        j                  d       y )N)shellz completion installed in green)fgz9Completion will take effect once you restart the terminalr   )
resilient_parsing
isinstancestrr   r   termuisechoechosysexit)r    r!   r"   r$   paths        r   install_callbackr0      sp    C))%E*tit
MM5'!:4&AgN
KKKLHHQKr   c                    |r| j                   r|S | j                         j                  }|sJ dj                  |j	                  dd      j                               }d}t        j                  d      }t        |t              r|}n|st               }||}t        |||      }t        j                  |       t        j                  d       y )Nz_{}_COMPLETE-_ r   )	prog_namecomplete_varr$   r   )r'   	find_root	info_nameformatreplaceupperr   r   r(   r)   r   r   r   r,   r-   r.   )	r    r!   r"   r5   r6   r$   r   detected_shellscript_contents	            r   show_callbackr>   *   s    C))))I9!(():):3)D)J)J)LMLEYY'UV%#(*%"E*,eN KKHHQKr   z--install-completionz)Install completion for the current shell.)callbackexpose_valuehelpz--show-completionzPShow completion for the current shell, to copy it or customize the installation.install_completionshow_completionc                      y N rB   rC   s     r   r   r   @   s      	r   z+Install completion for the specified shell.zRShow completion for the specified shell, to copy it or customize the installation.c                      y rE   rF   rG   s     r   r   r   S   s     	r   clictx_argsr5   r6   instructionc                    ddl m} d|vr |j                  dd       y|j                  d      \  }}}t	        j
                  |      }| |j                  d| dd       y || |||      }	|d	k(  r! |j                  |	j                                y
|dk(  r! |j                  |	j                                y
 |j                  d| dd       y)Nr   r   r3   zInvalid completion instruction.T)errzShell z not supported.sourcer   completezCompletion instruction "z" not supported.)r4   r   r,   	partitionr   get_completion_classrN   rO   )
rI   rJ   r5   r6   rK   r   r3   r$   comp_clscomps
             r   shell_completerT   i   s     
+54@ (11#6KE  44U;HfUG?3>C9l;DhDKKM" j DMMO$ FKK*;-7GHdSr   )$r   r-   collections.abcr   typingr   r4   r   r   _completion_classesr	   _completion_sharedr
   r   r   r   modelsr   paramsr   utilsr   _click_patchedtupler   Context	Parameterr0   r>   boolr   r   Commandr)   intrT   rF   r   r   <module>rc      s   	 
 *   $ 0 W W   +
%5I1E+F 
%	&.. 	1A1A 	# 	RU 	v~~ f.>.> s s .  &!8  #_		 	 		( "(!:	" %a			 	 		,(	(S#X&( ( 	(
 ( 	(r   