
    i9                     
   d dl Z d dlmZ d dlmZ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mZ d d	lmZ d
dlmZ d
dl mZ d
dlmZmZ  ej        ddddgi          Z e j        e          Z	 d dlZn# e $ r dZY nw xY w	 d dl!mZ" e#                    e"           n# e $ r Y nw xY w	 d dl$mZ% e#                    e%           n# e $ r Y nw xY wde&ddfdZ'e(                                d ej)        dd          fdee&dz   ej)        dde'          f         de&ddfd            Z(d e*e         defd!Z+	 dJd"d#d$ddd%ddddd&
d'edz  d(e,d)e-d*e&d+e*e         dz  d,e-dz  d-e,d.e,d/e,dz  d0e,dz  d1e&d2e,dz  ddfd3Z.e/                                	 dJd"d#d$dd%ddd$dd4	d'eedz   ej0        d5          f         d(ee, ej)        d6          f         d)ee- ej)        d7d89          f         d*ee& ej)        d:          f         d;ee*e         dz   ej)        d<          f         d-ee, ej)        d=          f         d/ee,dz   ej)        d>          f         d0ee,dz   ej)        d?d@dA          f         d1ee& ej)        dB          f         d2ee,dz   ej)        dC          f         defdD            Z1e/                                	 dJdEd#ddd%ddd$ddF	d'eedz   ej0        d5          f         d(ee, ej)        d6          f         d)ee- ej)        d7d89          f         d*ee& ej)        d:          f         d,ee-dz   ej)        dG          f         d-ee, ej)        d=          f         d/ee,dz   ej)        d>          f         d0ee,dz   ej)        d?d@dA          f         d1ee& ej)        dB          f         d2ee,dz   ej)        dC          f         defdH            Z2dKdIZ3dS )L    N)Path)	AnnotatedAny)ValidationError)print)Tree)FastAPIConfig)get_import_data"get_import_data_from_import_string)FastAPICLIException   )__version__)setup_logging)get_rich_toolkitget_uvicorn_log_configrichhelp_option_namesz-hz--help)rich_markup_modecontext_settingsappvaluereturnc                 `    | r+t          dt           d           t          j                    d S )NzFastAPI CLI version: [green]z[/green])r   r   typerExit)r   s    I/var/www/cyber-strat/venv/lib/python3.11/site-packages/fastapi_cli/cli.pyversion_callbackr   3   s:     B[BBBCCCjll     FzEnable verbose output)helpversionz	--versionzShow the version and exit.)r    callbackverbosec                 Z    |rt           j        nt           j        }t          |           dS )u  
    FastAPI CLI - The [bold]fastapi[/bold] command line app. 😎

    Manage your [bold]FastAPI[/bold] projects, run your FastAPI apps, and more.

    Read more in the docs: [link=https://fastapi.tiangolo.com/fastapi-cli/]https://fastapi.tiangolo.com/fastapi-cli/[/link].
    )levelN)loggingDEBUGINFOr   )r!   r#   	log_levels      r   r"   r"   9   s-    $ "):glI	""""""r   module_pathsc                    | d         }|                                 r
d|j         n	d|j         }t          |          }|                                r|                    d           |}| dd          D ]h}|                                 r
d|j         n	d|j         }|                    |          }|                                r|                    d           i|S )Nr   u   🐍 u   📁 u   [dim]🐍 __init__.py[/dim]r   )is_filenamer   is_diradd)r*   rootr-   	root_treetreesub_pathsub_names          r   _get_module_treer5   P   s    ?D"&,,..I496Idi6I6IDT

I{{}} 53444D $ 4 4'/'7'7'9'9V#HM###?Vx}?V?V 	 xx!!?? 	4HH2333r   z	127.0.0.1i@  T )
hostportreloadreload_dirsworkers	root_pathr   
entrypointproxy_headersforwarded_allow_ipspathr7   r8   r9   r:   r;   r<   commandr   r=   r>   r?   c                T	   t                      5 }|dk    rdnd}|                    d| dd           |                                 |                    d           |	rV| s|rR|                                 |                    d	           |                                 t	          j        d
          	 t          j        |	          }n# t          $ r}|                                 |                    d           |                                 |	                                D ]H}d
                    d |d         D                       }|                    d| d|d                     I|                                 t	          j        d
          d d }~ww xY w	 | s|rt          | |          }n*|j        rt          |j                  }nt                      }nT# t          $ rG}|                                 |                    d|            t	          j        d
          d d }~ww xY wt                              d|j        j                    t                              d|j        j                    |j        }|j        }|                    d|j                    |                                 |j        r?t-          |j                  }|                    |d           |                                 |                    dd           |                                 |                    d|j         d|j         d           |                                 |                    d| dd            d!| d"| }| d#}|                                 |                    d$| d%| dd&| d%| dd'           |dk    r+|                                 |                    d(d)           t0          st          d*          d |                                 |                    d+           |                                 t1          j        |||||rd, |D             nd |||
|t5                      -
  
         d d d            d S # 1 swxY w Y   d S ).Ndevdevelopment
productionz	Starting u    server 🚀FastAPI)tagzYSearching for package file structure from directories with [blue]__init__.py[/blue] fileszD[error]Cannot use --entrypoint together with path or --app argumentsr   )code)r=   z/[error]Invalid configuration in pyproject.toml:.c              3   4   K   | ]}t          |          V  d S N)str).0locs     r   	<genexpr>z_run.<locals>.<genexpr>   s(       B BcS B B B B B Br   rN   u     [red]•[/red] z: msg)r@   app_namez[error]zImporting from zImporting module modulezIImporting the FastAPI app object from the module with the following code:rH   z[underline]from [bold]z[/bold] import [bold]z[/bold]zUsing import string: [blue]z[/]r   zhttp://:z/docszServer started at [link=]zDocumentation at [link=serverzERunning in development mode, for production use: [bold]fastapi run[/]tipz;Could not import Uvicorn, try running 'pip install uvicorn'zLogs:c                 P    g | ]#}t          |                                          $S  )rL   resolve)rM   	directorys     r   
<listcomp>z_run.<locals>.<listcomp>   s,    GGGiY&&(())GGGr   )
r   r7   r8   r9   r:   r;   r<   r>   r?   
log_config)r   print_title
print_liner   r   r   r	   rY   r   errorsjoinr
   r=   r   r   loggerdebugmodule_dataextra_sys_pathmodule_import_strimport_stringr*   r5   rQ   uvicornrunr   )r@   r7   r8   r9   r:   r;   r<   rA   r   r=   r>   r?   toolkitserver_typeconfigeerrorfieldimport_datarc   rf   r1   urlurl_docss                           r   _runrr   e   s    
		 u
w'.%'7'7mm\AAAAyQQQg	
 	
 	
  	%4 	%3 	%   MMV      *!$$$$	/"*jAAAFF 	/ 	/ 	/   MMKLLL    K K B BU5\ B B BBBI%II5<IIJJJJ   *!$$$$.	/	/ 0s 0-4#FFF" 0@ARSS-//" 	/ 	/ 	/   MM-A--(((*!$$$$.	/
 	O{'>'MOOPPPT)@)RTTUUU!-#1D(BDDEEE# 	!()ABBIMM)M222   W 	 	
 	
 	
 	v[%BvvYdYmvvv	
 	
 	
 	<-<<< 	 	
 	
 	

 &%%t%%===5s55S555>h>>>>> 	 	
 	
 	
 e   MMW    
  	%M  	g GG;GGGG' 3-//	
 	
 	
 	
Mu
 u
 u
 u
 u
 u
 u
 u
 u
 u
 u
 u
 u
 u
 u
 u
 u
 u
s^   B'R7CR
F CFF  R$A G%$R%
H6/AH11H66IRR!$R!)	r7   r8   r9   
reload_dirr<   r   r=   r>   r?   zA path to a Python file or package directory (with [blue]__init__.py[/blue] files) containing a [bold]FastAPI[/bold] app. If not provided, a default set of paths will be tried.zThe host to serve on. For local development in localhost use [blue]127.0.0.1[/blue]. To enable public access, e.g. in a container, use all the IP addresses available with [blue]0.0.0.0[/blue].zThe port to serve on. You would normally have a termination proxy on top (another program) handling HTTPS on port [blue]443[/blue] and HTTP on port [blue]80[/blue], transferring the communication to your app.PORT)r    envvarzEnable auto-reload of the server when (code) files change. This is [bold]resource intensive[/bold], use it only during development.rs   zRSet reload directories explicitly, instead of using the current working directory.zThe root path is used to tell your app that it is being served to the outside world with some [bold]path prefix[/bold] set up in some termination proxy or similar.zThe name of the variable that contains the [bold]FastAPI[/bold] app in the imported module or package. If not provided, it is detected automatically.z--entrypointz-ezNThe FastAPI app import string in the format 'some.importable_module:app_name'.zdEnable/Disable X-Forwarded-Proto, X-Forwarded-For, X-Forwarded-Port to populate remote address info.ziComma separated list of IP Addresses to trust with proxy headers. The literal '*' means trust everything.c       	         :    t          | |||||||d||	           dS )u  
    Run a [bold]FastAPI[/bold] app in [yellow]development[/yellow] mode. 🧪

    This is equivalent to [bold]fastapi run[/bold] but with [bold]reload[/bold] enabled and listening on the [blue]127.0.0.1[/blue] address.

    It automatically detects the Python module or package that needs to be imported based on the file or directory path passed.

    If no path is passed, it tries with:

    - [blue]main.py[/blue]
    - [blue]app.py[/blue]
    - [blue]api.py[/blue]
    - [blue]app/main.py[/blue]
    - [blue]app/app.py[/blue]
    - [blue]app/api.py[/blue]

    It also detects the directory that needs to be added to the [bold]PYTHONPATH[/bold] to make the app importable and adds it.

    It detects the [bold]FastAPI[/bold] app object to use. By default it looks in the module or package for an object named:

    - [blue]app[/blue]
    - [blue]api[/blue]

    Otherwise, it uses the first [bold]FastAPI[/bold] app found in the imported module or package.
    rC   )r@   r7   r8   r9   r:   r<   r   r=   rA   r>   r?   Nrr   )
r@   r7   r8   r9   rs   r<   r   r=   r>   r?   s
             r   rC   rC      sG    x 	#/     r   z0.0.0.0)	r7   r8   r9   r;   r<   r   r=   r>   r?   zIUse multiple worker processes. Mutually exclusive with the --reload flag.c       	         :    t          | |||||||d||	           dS )u  
    Run a [bold]FastAPI[/bold] app in [green]production[/green] mode. 🚀

    This is equivalent to [bold]fastapi dev[/bold] but with [bold]reload[/bold] disabled and listening on the [blue]0.0.0.0[/blue] address.

    It automatically detects the Python module or package that needs to be imported based on the file or directory path passed.

    If no path is passed, it tries with:

    - [blue]main.py[/blue]
    - [blue]app.py[/blue]
    - [blue]api.py[/blue]
    - [blue]app/main.py[/blue]
    - [blue]app/app.py[/blue]
    - [blue]app/api.py[/blue]

    It also detects the directory that needs to be added to the [bold]PYTHONPATH[/bold] to make the app importable and adds it.

    It detects the [bold]FastAPI[/bold] app object to use. By default it looks in the module or package for an object named:

    - [blue]app[/blue]
    - [blue]api[/blue]

    Otherwise, it uses the first [bold]FastAPI[/bold] app found in the imported module or package.
    rh   )r@   r7   r8   r9   r;   r<   r   r=   rA   r>   r?   Nrw   )
r@   r7   r8   r9   r;   r<   r   r=   r>   r?   s
             r   rh   rh   W  sG    x 	#/     r   c                  "    t                       d S rK   r   rX   r   r   mainrz     s    EEEEEr   rK   )r   N)4r&   pathlibr   typingr   r   r   pydanticr   r   r   	rich.treer   fastapi_cli.configr	   fastapi_cli.discoverr
   r   fastapi_cli.exceptionsr   r6   r   r   	utils.clir   r   Typerr   	getLogger__name__ra   rg   ImportErrorfastapi_cloud_cli.clifastapi_cloud_cli	add_typerfastapi_new.clifastapi_new_cliboolr   r"   Optionlistr5   rL   intrr   rA   ArgumentrC   rh   rz   rX   r   r   <module>r      sL	          ! ! ! ! ! ! ! !  $ $ $ $ $ $             , , , , , , T T T T T T T T 6 6 6 6 6 6       " " " " " " ? ? ? ? ? ? ? ?ek/BT8DT.U   
	8	$	$NNNN   GGG	      MM#$$$$ 	 	 	D		      MM/"""" 	 	 	D	D T      	 EL-DEEE# #t:EU	
 	
 	
	# # 
# # # #,4: $    , D
 %)!&*D
 D
 D

+D
 D
 	D

 D
 dd"D
 4ZD
 D
 D
 
tD
 d
D
 D
 tD
 
D
 D
 D
 D
N  	g 	 	 	 	 	 	 	 	 	Ag g g
t D	
 	
 	
	g  T	
 	
 	
	g  d	
 	
 	
	g*  W	
 	
 	
	+g6 T
Te	
 	
 	
	7gB  w	
 	
 	
	CgN 
d
 i	
 	
 	
	
OgZ d
a	
 	
 	
	[gj w	
 	
 	
	kgv #d
|	
 	
 	
	wgB 	Cg g g gT  	g 	 	 	 	 	 	 	 	 	Ag g g
t D	
 	
 	
	g  T	
 	
 	
	g  d	
 	
 	
	g*  W	
 	
 	
	+g6 d
\	
 	
 	
	7gB  w	
 	
 	
	CgN 
d
 i	
 	
 	
	
OgZ d
a	
 	
 	
	[gj w	
 	
 	
	kgv #d
|	
 	
 	
	wgB 	Cg g g gT
 
 
 
 
 
s6   8A= =BBB' 'B/.B/3C CC