
    d$                    B   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 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 erLd dlZej        dk    rd dlmZ n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  d dl!m"Z" d dl#m$Z$ d dl#m%Z%  G d de          Z&dS )    )annotations)TYPE_CHECKING)Any)ContextManager)cast)BaseCommand)Style)StringInput)NullIO)	VerbosityTableSeparatorN)      )Literal)Argument)Option)IOProgressBarProgressIndicatorQuestion)RowsTablec                      e Zd ZU g Zded<   g Zded<   g Zded<   g Zded<   g Zded	<   dZ fdZ	e
d[d            ZdZdZd\dZd]dZd^d_dZd^d_dZd`dZd`dZ	 dadbd$Zd^dcd'Zd^dcd(Z	 	 	 ddded-Z	 d^dfd2Z	 	 	 dgdhd8Zdid:Zd^djd=Zd^dkd?Zdej        fdldBZdej        fdldCZdmdDZ dmdEZ!dmdFZ"dndodJZ#	 	 	 dpdqdQZ$	 	 	 dpdrdUZ%	 	 	 dgdsdXZ&dmdYZ' xZ(S )tCommandzlist[Argument]	argumentszlist[Option]options	list[str]aliasesusageszlist[BaseCommand]commandsreturnNonec                V    d | _         t                                                       d S N)_iosuper__init__)self	__class__s    Y/home/feoh/.local/pipx/venvs/poetry/lib/python3.11/site-packages/cleo/commands/command.pyr,   zCommand.__init__*   s&        r   c                    | j         S r)   )r*   r-   s    r/   ioz
Command.io.   s	    xr0   c                    | j         D ]}| j                            |           | j        D ]}| j                            |           d S r)   )r    _definitionadd_argumentr!   
add_option)r-   argumentoptions      r/   	configurezCommand.configure2   sb     	4 	4H))(3333l 	0 	0F''////	0 	0r0   r3   intc                \    || _         	 |                                 S # t          $ r Y dS w xY w)N   )r*   handleKeyboardInterrupt)r-   r3   s     r/   executezCommand.execute:   s>    	;;==   	 	 	11	s    
++c                    t                      )z'
        Executes the command.
        )NotImplementedErrorr2   s    r/   r>   zCommand.handleB   s     "###r0   Nnamestrargs
str | Nonec                    |d}t          |          }| j        J | j                            |          }| j                            || j                            |                    S )z'
        Call another command.
        N )r
   applicationget_run_commandr*   
with_inputr-   rC   rE   inputcommands        r/   callzCommand.callH   si     <DD!!+++"&&t,,,,Wdh6I6I%6P6PQQQr0   c                    |d}t          |          }| j        J | j                            |          }| j                            |t	          |                    S )z0
        Call another command silently.
        NrH   )r
   rI   rJ   rK   r   rM   s        r/   call_silentzCommand.call_silentU   s_     <DD!!+++"&&t,,,,WfUmmDDDr0   r   c                @    | j         j                            |          S )z6
        Get the value of a command argument.
        )r*   rN   r8   r-   rC   s     r/   r8   zCommand.argumentb   s     x~&&t,,,r0   c                @    | j         j                            |          S )z4
        Get the value of a command option.
        )r*   rN   r9   rT   s     r/   r9   zCommand.optionh   s     x~$$T***r0   F(?i)^yquestiondefaultbooltrue_answer_regexc                    ddl m}  ||||          }t          t          |                    | j                            S )z3
        Confirm a question with the user.
        r   ConfirmationQuestion)rX   rZ   )cleo.ui.confirmation_questionr]   r   rY   askr*   )r-   rW   rX   rZ   r]   confirmations         r/   confirmzCommand.confirmn   sX     	GFFFFF++g9J
 
 
 D,**4844555r0   str | Question
Any | Nonec                |    ddl m} t          ||          s |||          }|                    | j                  S )z,
        Prompt the user for input.
        r   r   rX   )cleo.ui.questionr   
isinstancer_   r*   r-   rW   rX   r   s       r/   r_   zCommand.ask{   sP     	.-----(H-- 	;x':::H||DH%%%r0   c                    ddl m} t          ||          s |||          }|                                 |                    | j                  S )zQ
        Prompt the user for input but hide the answer from the console.
        r   r   re   )rf   r   rg   hider_   r*   rh   s       r/   secretzCommand.secret   s]     	.-----(H-- 	;x':::H||DH%%%r0   choicesattempts
int | Nonemultiplec                    ddl m}  ||||          }|                    |           |                    |           |                    | j                  S )zH
        Give the user a single choice from an list of answers.
        r   ChoiceQuestion)cleo.ui.choice_questionrr   set_max_attemptsset_multi_selectr_   r*   )r-   rW   rl   rX   rm   ro   rr   choices           r/   rv   zCommand.choice   se     	;:::::'7;;))))))zz$(###r0   type2Literal['choice'] | Literal['confirmation'] | Nonekwargsr   c                |    ddl m} ddlm} ddlm} |s	 ||fi |S |dk    r	 ||fi |S |dk    r	 ||fi |S dS )z7
        Returns a Question of specified type.
        r   rq   r\   r   rv   r`   N)rs   rr   r^   r]   rf   r   )r-   rW   rw   ry   rr   r]   r   s          r/   create_questionzCommand.create_question   s     	;:::::FFFFFF------ 	08H/////8!>(55f555>!!'';;F;;; "!r0   headerrowsRows | Nonestyler   c                    ddl m}  || j        |          }|r|                    |g           |r|                    |           |S )z*
        Return a Table instance.
        r   r   )r   )cleo.ui.tabler   r*   set_headersset_rows)r-   r|   r}   r   r   tables         r/   r   zCommand.table   si     	('''''dhe,,, 	(vh''' 	!NN4   r0   r   c                "    ddl m}  |            S )z3
        Return a TableSeparator instance.
        r   r   )cleo.ui.table_separatorr   )r-   r   s     r/   table_separatorzCommand.table_separator   s$     	;:::::~r0   headersr   c                \    |                      |||          }|                                 dS )z0
        Format input to textual table.
        N)r   render)r-   r   r}   r   r   s        r/   render_tablezCommand.render_table   s*     

7D%00r0   textc                V    |r
d| d| d}n|}| j                             |           dS )zd
        Writes a string without a new line.
        Useful if you want to use overwrite().
        <></>N)r*   write)r-   r   r   styleds       r/   r   zCommand.write   sE    
  	******FFFvr0   	verbosityr   c                Z    |r
d| d| d}n|}| j                             ||           dS )z7
        Write a string as information output.
        r   r   r   )r   N)r*   
write_liner-   r   r   r   r   s        r/   linezCommand.line   sL      	******FFFFi88888r0   c                X    |r
d| d| d}n|}| j                             ||           dS )zA
        Write a string as information output to stderr.
        r   r   r   N)r*   write_error_liner   s        r/   
line_errorzCommand.line_error   sI      	******FFF!!&)44444r0   c                2    |                      |d           dS )zw
        Write a string as information output.

        :param text: The line to write
        :type text: str
        infoNr   r-   r   s     r/   r   zCommand.info  s     			$r0   c                2    |                      |d           dS )zs
        Write a string as comment output.

        :param text: The line to write
        :type text: str
        commentNr   r   s     r/   r   zCommand.comment  s     			$	"""""r0   c                2    |                      |d           dS )zt
        Write a string as question output.

        :param text: The line to write
        :type text: str
        rW   Nr   r   s     r/   rW   zCommand.question   s     			$
#####r0   r   maxr   c                2    ddl m}  || j        |          S )z,
        Creates a new progress bar
        r   r   )r   )cleo.ui.progress_barr   r*   )r-   r   r   s      r/   progress_barzCommand.progress_bar)  s-     	544444{48----r0   d   fmtintervalvalueslist[str] | Noner   c                4    ddl m}  || j        |||          S )z3
        Creates a new progress indicator.
        r   r   )cleo.ui.progress_indicatorr   r3   )r-   r   r   r   r   s        r/   progress_indicatorzCommand.progress_indicator1  s0     	A@@@@@  #x@@@r0   start_messageend_message!ContextManager[ProgressIndicator]c                \    |                      |||          }|                    ||          S )z:
        Automatically spin a progress indicator.
        )r   auto)r-   r   r   r   r   r   spinners          r/   spinzCommand.spin>  s/     ))#x@@||M;777r0   fgbgc                    t          |||          }| j        j        j                            ||           | j        j        j                            ||           dS )z"
        Adds a new style
        N)r	   r*   output	formatter	set_styleerror_output)r-   rC   r   r   r!   r   s         r/   	add_stylezCommand.add_styleM  sV     b"g&&!++D%888'11$>>>>>r0   c                :    | j                             |           dS )zx
        Overwrites the current line.

        It will not add a new line so use line('')
        if necessary.
        N)r*   	overwriter   s     r/   r   zCommand.overwrite[  s      	4     r0   )r&   r'   )r&   r   )r3   r   r&   r;   )r&   r;   r)   )rC   rD   rE   rF   r&   r;   )rC   rD   r&   r   )FrV   )rW   rD   rX   rY   rZ   rD   r&   rY   )rW   rb   rX   rc   r&   r   )NNF)rW   rD   rl   r"   rX   rc   rm   rn   ro   rY   r&   r   )rW   rD   rw   rx   ry   r   r&   r   )NNN)r|   rF   r}   r~   r   rF   r&   r   )r&   r   )r   rD   r}   r   r   rF   r&   r'   )r   rD   r   rF   r&   r'   )r   rD   r   rF   r   r   r&   r'   )r   rD   r&   r'   )r   )r   r;   r&   r   )Nr   N)r   rF   r   r;   r   r   r&   r   )r   rD   r   rD   r   rF   r   r;   r   r   r&   r   )
rC   rD   r   rF   r   rF   r!   r   r&   r'   ))__name__
__module____qualname__r    __annotations__r!   r#   r$   r%   r,   propertyr3   r:   r@   r>   rP   rR   r8   r9   ra   r_   rk   rv   r{   r   r   r   r   r   NORMALr   r   r   r   rW   r   r   r   r   r   __classcell__)r.   s   @r/   r   r   "   sv         "I""""GGF"$H$$$$         X0 0 0 0   $ $ $ $R R R R RE E E E E- - - -+ + + + NV6 6 6 6 6	& 	& 	& 	& 	&& & & & &" ##$ $ $ $ $. DH< < < < <0 "  	    *           
 
 
 
 
 !(/	9 9 9 9 9& !(/	5 5 5 5 5        # # # #$ $ $ $. . . . . #'	A A A A A" #'8 8 8 8 8$ $(? ? ? ? ?! ! ! ! ! ! ! !r0   r   )'
__future__r   typingr   r   r   r   cleo.commands.base_commandr   cleo.formatters.styler	   cleo.io.inputs.string_inputr
   cleo.io.null_ior   cleo.io.outputs.outputr   r   r   sysversion_infor   typing_extensionscleo.io.inputs.argumentr   cleo.io.inputs.optionr   
cleo.io.ior   r   r   r   r   rf   r   r   r   r   r    r0   r/   <module>r      s   " " " " " "                   ! ! ! ! ! !       2 2 2 2 2 2 ' ' ' ' ' ' 3 3 3 3 3 3 " " " " " " , , , , , , 2 2 2 2 2 2  $JJJ
6!!"""""""------000000,,,,,,000000<<<<<<))))))""""""######@! @! @! @! @!k @! @! @! @! @!r0   