o
    SDi	                     @   s  d dl mZ d dlmZ d dlZd dlmZ d dlmZ d dl	m
Z
mZ e Zeeejddf Zejd	d
ddZejdd
ddZee defddZdedefddZejdddd	
d5deeejdddf deeejdddf deeejd d! d"d#f ded$df
d%dZejd&d'd(d	
d5d&eeejd)d*df deeejdddf deeejd+d! d"d#f ded$df
d,d-Ze ejdd.d/ed0d1fdefd2d3Zed4kre  dS dS )6    )date)	AnnotatedN)Console)Syntax)render_model_by_pathrender_module_by_pathzOutput code without color)helpcadwynFz,Modern Stripe-like API versioning in FastAPI)nameadd_completionr   renderzRRender pydantic models and enums from a certainn version and output them to stdoutvaluec                 C   s*   | rddl m} td|  tjd S )N   )__version__zCadwyn ) r   typerechoExit)r   r    r   H/var/www/Datamplify/venv/lib/python3.10/site-packages/cadwyn/__main__.pyversion_callback   s
   r   coderawc                 C   s*   |r	t |  d S tt| ddd d S )NpythonT)line_numbers)r   r   _CONSOLEprintr   )r   r   r   r   r   output_code$   s   r   modelzWRender a concrete pydantic model or enum from a certain version and output it to stdoutzRender a single model or enum)r
   r   
short_helpz<module>:<attribute>z"Python path to the model to render)metavarr   appz"Python path to the main Cadwyn appversionc                 C      t t| S Nstrr   fromisoformatsr   r   r   <lambda>3       r*   zISO-VERSION)parserr    returnc                 C      t t| ||| d S r$   )r   r   )r   r!   r"   r   r   r   r   r   +      modulezfRender all versioned models and enums within a module from a certain version and output them to stdoutz1Render all models and enums from an entire modulez<module>z#Python path to the module to renderc                 C   r#   r$   r%   r(   r   r   r   r*   A   r+   c                 C   r.   r$   )r   r   )r0   r!   r"   r   r   r   r   render_module9   r/   r1   z-Vz	--versionT)callbackis_eagerc                 C   s   d S r$   r   )r"   r   r   r   mainG   s   r4   __main__)F)datetimer   typingr   r   rich.consoler   rich.syntaxr   cadwyn._renderr   r   r   boolOption_RAW_ARGTyperr!   render_subapp	add_typerr   r&   r   commandArgumentr   r1   r2   r4   __name__r   r   r   r   <module>   s~    
				
