
    =)i                        d dl Z d dlZd dlmZ d dlmZ d dl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j.                  dej0                  dedefdZdej.                  dej0                  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   )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       -/mnt/e/genesis-system/lib/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
                  | 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
   clicksechoechosysexit)r   r   r   r!   paths        r   install_callbackr-      sg    C))%E*tit	KK5'24&9gF	JJJK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   r2   r3   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 
JJ~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 r?   r@   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 rB   rC   rD   s     r   r   r   S   s     	r   clictx_argsr2   r3   instructionc                    dd l }dd l}d|vr |j                  dd       y|j                  d      \  }}}|j                  j                  |      }| |j                  d| dd       y || |||      }	|d	k(  r! |j                  |	j                                y|d
k(  r! |j                  |	j                                y |j                  d| dd       y)Nr   r0   zInvalid completion instruction.T)errr   zShell z not supported.sourcecompletezCompletion instruction "z" not supported.)r'   click.shell_completionr)   	partitionshell_completionget_completion_classrK   rL   )
rF   rG   r2   r3   rH   r'   r0   r!   comp_clscomps
             r   shell_completerS   i   s     !
+

4$? (11#6KE %%::5AH

VE7/2=C9l;Dh

4;;=! j 

4==?# EJJ)+6FGTRr   )"r   r*   collections.abcr   typingr   r'   _completion_classesr   _completion_sharedr   r   r	   r
   modelsr   paramsr   utilsr   _click_patchedtupler   Context	Parameterr-   r;   boolr   r   Commandr&   intrS   rC   r   r   <module>rb      s~   	 
 *   0 W W   +
%5I1E+F 
%	%-- 	 	 	PS 	u}} U__ S S .  &!8  #_		 	 		( "(!:	" %a			 	 		,)	)S#X&) ) 	)
 ) 	)r   