
    Ki              	          d dl Z d dlZd dlmZmZ d dlmZ d dlmZm	Z	m
Z
mZmZ d dlmZ ej                  dk  rd dlmZ nd dlmZ erd dlma  ed	      Zda	 	 dd
ede j*                  dz  de
d   fdZedededdef   f   de
d   defd       Zededef   de
d   defd       Zedddededde	f   f   dedz  de	fd       Zedddede	f   dedz  de	fd       Zdddedz  fdZy)    N)Callable	Coroutine)partial)TYPE_CHECKINGAnyLiteralTypeVaroverload)ResultAction)      )assert_neverAppVcommandboundbackend)asynciotrioc                    t        j                  |       s%| |        S  | |j                  i |j                  S |dk(  rGddl}||j                   |              S |j                   | |j                  i |j                        S |dk(  rIddl}||j                  |       S |j                  t        | g|j                  i |j                        S t        |       y)a  Run a command, handling both sync and async cases.

    If the command is async, an async context will be created to run it.

    Parameters
    ----------
    command : Callable
        The command to execute.
    bound : inspect.BoundArguments | None
        Bound arguments for the command. If None, command is called with no arguments.
    backend : Literal["asyncio", "trio"]
        The async backend to use if the command is async.

    Returns
    -------
    return_value: Any
        The value the command function returns.
    Nr   r   r   )	inspectiscoroutinefunctionargskwargsr   runr   r   r   )r   r   r   r   r   s        Y/home/jay/workspace/scripts/.codegraph-venv/lib/python3.12/site-packages/cyclopts/_run.py_run_maybe_async_commandr      s    . &&w/=9EJJ7%,,77)=;;wy));;w

CellCDD	F	=88G$$88GGIejjIELLIJJW    callable.result_actionreturn_valuereturnc                    y N r    r!   s     r   r   r   F   s    orr   c                    y r%   r&   r'   s     r   r   r   J   s    X[r   r!   c                    y r%   r&   r'   s     r   r   r   N   s     r   c                    y r%   r&   r'   s     r   r   r   T   s    _br   c               f    t         ddlm } |a t        |      }|j                  |         |       S )a  Run the given callable as a CLI command.

    The callable may also be a coroutine function.
    This function is syntax sugar for very simple use cases, and is roughly equivalent to:

    .. code-block:: python

        from cyclopts import App

        app = App()
        app.default(callable)
        app()

    Parameters
    ----------
    callable
        The function to execute as a CLI command.
    result_action
        How to handle the command's return value. If not specified, uses the default
        ``"print_non_int_sys_exit"`` which calls :func:`sys.exit` with the appropriate code.
        Can be set to ``"return_value"`` to return the result directly for testing/embedding.

    Example usage:

    .. code-block:: python

        import cyclopts


        def main(name: str, age: int):
            print(f"Hello {name}, you are {age} years old.")


        cyclopts.run(main)
    r   r   r)   )r   cyclopts.coredefault)r    r!   _Appapps       r   r   r   X   s/    J {-
M
*CKK5Lr   )Nr   )r   syscollections.abcr   r   	functoolsr   typingr   r   r   r	   r
   cyclopts._result_actionr   version_infotyping_extensionsr   r-   r   r   BoundArgumentsr   r   r&   r   r   <module>r9      sy    
 /  A A 0g.#!CL 
 ,0*3,,!!D(, &',^ 
 r(3	$a- 889 rPWXfPg rlm r 
 r 
 [(36" [9P [UV [ 
 [ 
dhsIdD#o667NZ]aNa 

 
QU b(38$ b<$;N bZ] b 
 b >B ,|d': ,r   