o
    NK&hy#                     @  s   d dl mZ d dlmZmZ d dlmZmZ d dlm	Z
 d dlm	Z	 d dlmZ G dd dZG dd	 d	eZG d
d deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZdS )    )annotations)ArgumentParser_ArgumentGroup)OptionalUnion)__version__)HTTPc                   @  sd   e Zd ZU ded< ded< g Zded< dd	d
ZdddZedddZddddZ	dddZ
dS )GroupOptional[str]namez%Union[ArgumentParser, _ArgumentGroup]	containerzlist[type[Group]]	_registryreturnNonec                 C  s   t j|  d S N)r	   r   append)cls r   F/var/www/html/venv/lib/python3.10/site-packages/sanic/cli/arguments.py__init_subclass__   s   zGroup.__init_subclass__parserr   titlec                 C  s0   || _ |r| j jd| d| _d S | j | _d S )Nz  )r   )r   add_argument_groupr   )selfr   r   r   r   r   __init__   s   zGroup.__init__c                 C  s   | || j }|S r   )r   )r   r   instancer   r   r   create   s   zGroup.createF)nullablec                O  s   | j  }|d  |d< |j|ddi| d|d    |d< |jd|d dd   g|dd  R dd	i| |rX|d dd  d
dd i}|jdi | d S d S )Nhelpaction
store_truezno z--no-r         store_false-_r   )r   add_mutually_exclusive_group
capitalizeadd_argumentlowerreplaceset_defaults)r   r   argskwargsgroupparamsr   r   r   add_bool_arguments!   s"   

zGroup.add_bool_argumentsc                 C  s   d S r   r   r   r,   r   r   r   prepare-   s    zGroup.prepareN)r   r   )r   r   r   r
   )r   r   )__name__
__module____qualname____annotations__r   r   r   classmethodr   r0   r2   r   r   r   r   r	      s   
 

r	   c                   @  s   e Zd ZdZdd ZdS )GeneralGroupNc                 C  sL   | j jdddt dt d | j jddd | j jd	d
dddgdd d S )Nz	--versionversionzSanic z
; Routing )r   r9   targeta  Path to your Sanic app instance.
	Example: path.to.server:app
If running a Simple Server, path to directory to serve.
	Example: ./
Additionally, this can be a path to a factory function
that returns a Sanic app instance.
	Example: path.to.server:create_app
r   r   ?serveexecz_Action to perform.
	serve: Run the Sanic app
	exec: Execute a command in the Sanic app context
)nargsdefaultchoicesr   )r   r(   r   __routing_version__r   r   r   r   attach3   s$   
zGeneralGroup.attachr3   r4   r5   r   rD   r   r   r   r   r8   0       r8   c                   @     e Zd ZdZdd ZdS )ApplicationGroupApplicationc                 C  s@   | j  }|jdddd |jdddddd	 | jd
dd d S )Nz	--factoryr    zFTreat app as an application factory, i.e. a () -> <Sanic app> callabler   r   z-sz--simplesimplezaRun Sanic as a Simple Server, and serve the contents of a directory
(module arg should be a path)destr   r   z--replz0Run the server with an interactive shell sessionr;   )r   r&   r(   r0   r   r.   r   r   r   rD   Z   s"   


zApplicationGroup.attachNrE   r   r   r   r   rH   W   rF   rH   c                   @  s    e Zd ZdZdd Zdd ZdS )HTTPVersionGroupzHTTP versionc                 C  s\   dd t j D }| jjddd|tdd | jjddd	d
dd | jjddd	ddd d S )Nc                 S  s   g | ]}|j qS r   )value).0httpr   r   r   
<listcomp>x   s    z+HTTPVersionGroup.attach.<locals>.<listcomp>z--httprR   r   zZWhich HTTP version to use: HTTP/1.1 or HTTP/3. Value should
be either 1, or 3. [default 1])rM   r   rA   typer   z-1append_constr"   zRun Sanic server using HTTP/1.1)rM   r   constr   z-3   zRun Sanic server using HTTP/3)r   __members__valuesr   r(   int)r   http_valuesr   r   r   rD   w   s.   
zHTTPVersionGroup.attachc                 C  s0   |j sdg|_ ttttt|j dd|_ d S )Nr"   T)reverse)rR   tuplesortedsetmapr   r1   r   r   r   r2      s   "zHTTPVersionGroup.prepareN)r3   r4   r5   r   rD   r2   r   r   r   r   rO   t   s    rO   c                   @  rG   )SocketGroupzSocket bindingc                 C  sH   | j jdddtdd | j jdddtd	d | j jd
ddtddd d S )Nz-Hz--hosthostz Host address [default 127.0.0.1]rM   rT   r   z-pz--portportzPort to serve on [default 8000]z-uz--unixunix zlocation of unix socketrM   rT   r@   r   )r   r(   strrZ   rC   r   r   r   rD      s,   
zSocketGroup.attachNrE   r   r   r   r   ra      rF   ra   c                   @  rG   )TLSGroupzTLS certificatec                 C  sV   | j jddtdd | j jddtdd | j jdd	td
dd | j jddddd d S )Nz--certcertz3Location of fullchain.pem, bundle.crt or equivalentrc   z--keykeyz/Location of privkey.pem or equivalent .key filez--tlsDIRr   zyTLS certificate folder with fullchain.pem and privkey.pem
May be specified multiple times to choose multiple certificates)metavarrT   r   r   z--tls-strict-hosttlshostr    z9Only allow clients that send an SNI matching server certsrL   )r   r(   rh   rC   r   r   r   rD      s2   
zTLSGroup.attachNrE   r   r   r   r   ri      rF   ri   c                   @  rG   )WorkerGroupWorkerc                 C  sZ   | j  }|jdddtddd |jddd	d
d |jddd	dd | jdddd d d S )Nz-wz	--workersworkersr"   z&Number of worker processes [default 1]rg   z--fastfastr    z(Set the number of workers to max allowedrL   z--single-processsinglez:Do not use multiprocessing, run server in a single processz--access-logs
access_logzdisplay access logsrM   r   r@   )r   r&   r(   rZ   r0   rN   r   r   r   rD      s6   

zWorkerGroup.attachNrE   r   r   r   r   ro      rF   ro   c                   @  rG   )DevelopmentGroupDevelopmentc                 C  sp   | j jddddd | j jdddd	dd
d | j jdddddd | j jdddddd | j jddddd d S )Nz--debugdebugr    zRun the server in debug moderL   z-rz--reloadz--auto-reloadauto_reloadz=Watch source directory for file changes and reload on changesz-Rz--reload-dirpathr   z0Extra directories to watch and reload on changesz-dz--devdevzdebug + auto reloadz
--auto-tlsauto_tlszUCreate a temporary TLS certificate for local development (requires mkcert or trustme))r   r(   rC   r   r   r   rD      sD   

zDevelopmentGroup.attachNrE   r   r   r   r   rv      rF   rv   c                   @  rG   )OutputGroupOutputc                 C  sN   | j ddddd | j dddd	d | jjd
dddd | j dddd d d S )Nz--coffeecoffeeFzUhm, coffee?)rM   r@   r   z--motdmotdTzShow the startup displayz-vz--verbositycountz;Control logging noise, eg. -vv or --verbosity=2 [default 0]rJ   z--noisy-exceptionsnoisy_exceptionsz&Output stack traces for all exceptionsru   )r0   r   r(   rC   r   r   r   rD   *  s0   
zOutputGroup.attachNrE   r   r   r   r   r}   '  rF   r}   N)
__future__r   argparser   r   typingr   r   sanic_routingr   rB   sanicsanic.http.constantsr   r	   r8   rH   rO   ra   ri   ro   rv   r}   r   r   r   r   <module>   s    $'&#!-