o
    Vh8                     @  sn   d dl m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 G d	d
 d
ZdS )    )annotationsN)Any)TextIO)shell_quote)CleoMissingArgumentsError)CleoValueError)
Definitionc                   @  s0  e Zd ZdZdOdPddZedQd
dZedQddZedRddZedSddZ	edSddZ
dTdUddZdVdUddZdWd d!ZdXd#d$ZdXd%d&ZdYdZd)d*Zd[d,d-ZdWd.d/Zd\d2d3Zd]d5d6Zd^d7d8Zd\d9d:Zd]d;d<Zd^d=d>Zd_d@dAZd`dCdDZ	EdadbdIdJZ	E	EdcdddKdLZdWdMdNZdS )eInputzJ
    This class is the base class for concrete Input implementations.
    N
definitionDefinition | NonereturnNonec                 C  sF   |  d | _ i | _i | _d | _|d u rt | _d S | | |   d S N)_stream_options
_arguments_interactiver   _definitionbindvalidateselfr
    r   h/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/cleo/io/inputs/input.py__init__   s   
zInput.__init__dict[str, Any]c                 C     i | j j| jS r   )r   argument_defaultsr   r   r   r   r   	arguments       zInput.argumentsc                 C  r   r   )r   option_defaultsr   r   r   r   r   options$   r    zInput.optionsr   c                 C  s   | j S r   r   r   r   r   r   stream(   s   zInput.stream
str | Nonec                 C     t )zR
        Returns the first argument from the raw parameters (not parsed).
        NotImplementedErrorr   r   r   r   first_argument,   s   zInput.first_argumentc                 C  r&   r   r'   r   r   r   r   script_name3   s   zInput.script_name lengthintdefaultstrc                 C     |   s|S | j|S )zM
        Reads the given amount of characters from the input stream.
        )is_interactiver   readr   r,   r.   r   r   r   r2   7      z
Input.readc                 C  r0   )z5
        Reads a line from the input stream.
        )r1   r   readliner3   r   r   r   	read_line@   r4   zInput.read_linec                 C  s   | j   dS )z#
        Closes the input.
        N)r   closer   r   r   r   r8   I   s   zInput.closeboolc                 C  s   | j jS )z6
        Returns whether the input is closed.
        )r   closedr   r   r   r   	is_closedO   s   zInput.is_closedc                 C  s   | j d u rdS | j S )NTr   r   r   r   r   r1   U   s   zInput.is_interactiveTinteractivec                 C  
   || _ d S r   r<   )r   r=   r   r   r   r=   X      
zInput.interactiver   c                 C  s   i | _ i | _|| _|   dS )zm
        Binds the current Input instance with
        the given definition's arguments and options.
        N)r   r   r   _parser   r   r   r   r   [   s   z
Input.bindc                 C  sP   g }| j jD ]}|j| jvr| r||j q|r&tdd| dd S )Nz Not enough arguments (missing: "z, z"))r   r   namer   is_requiredappendr   join)r   missing_argumentsargumentr   r   r   r   f   s   zInput.validaterA   r   c                 C  >   | j |std| d|| jv r| j| S | j |jS NzThe argument "" does not exist)r   has_argumentr   r   rF   r.   r   rA   r   r   r   rF   r   
   

zInput.argumentvaluec                 C  *   | j |std| d|| j|< d S rH   )r   rJ   r   r   r   rA   rM   r   r   r   set_argument{      zInput.set_argumentc                 C     | j |S r   )r   rJ   rK   r   r   r   rJ         zInput.has_argumentc                 C  rG   NzThe option "--rI   )r   
has_optionr   r   optionr.   rK   r   r   r   rV      rL   zInput.optionc                 C  rN   rT   )r   rU   r   r   rO   r   r   r   
set_option   rQ   zInput.set_optionc                 C  rR   r   )r   rU   rK   r   r   r   rU      rS   zInput.has_optiontokenc                 C  s   t d|r|S t|S )Nz^[\w-]+$)rematchr   )r   rX   r   r   r   escape_token   s   zInput.escape_tokenr$   c                 C  r>   r   r#   )r   r$   r   r   r   
set_stream   r?   zInput.set_streamFvaluesstr | list[str]only_paramsc                 C  r&   )zR
        Returns true if the raw parameters (not parsed) contain a value.
        r'   )r   r]   r_   r   r   r   has_parameter_option   s   zInput.has_parameter_optionc                 C  r&   )zA
        Returns the value of a raw option (not parsed).
        r'   )r   r]   r.   r_   r   r   r   parameter_option   s   	zInput.parameter_optionc                 C  r&   r   r'   r   r   r   r   r@      s   zInput._parser   )r
   r   r   r   )r   r   )r   r   )r   r%   )r+   )r,   r-   r.   r/   r   r/   )r5   r+   )r   r   )r   r9   )T)r=   r9   r   r   )r
   r   r   r   )rA   r/   r   r   )rA   r/   rM   r   r   r   )rA   r/   r   r9   )rX   r/   r   r/   )r$   r   r   r   )F)r]   r^   r_   r9   r   r9   )FF)r]   r^   r.   r   r_   r9   r   r   )__name__
__module____qualname____doc__r   propertyr   r"   r$   r)   r*   r2   r7   r8   r;   r1   r=   r   r   rF   rP   rJ   rV   rW   rU   r[   r\   r`   ra   r@   r   r   r   r   r	      sF    	
	





	


	


r	   )
__future__r   rY   typingr   r   cleo._compatr   cleo.exceptionsr   r   cleo.io.inputs.definitionr   r	   r   r   r   r   <module>   s    