
    k7i              	          S SK r S SKrS SKJrJr  S SKJr  S SKJrJ	r	J
r
JrJr  S SKJr  \R                  S:  a  S SKJr  OS SKJr  \(       a  S SKJq  \" S	5      rSq  SS
\S\ R*                  S-  S\
S   4S jjr\S\S\SS\4   4   S\
S   S\4S j5       r\S\S\4   S\
S   S\4S j5       r\SS.S\S\SS\	4   4   S\S-  S\	4S jj5       r\SS.S\S\	4   S\S-  S\	4S jj5       rSS.S\S-  4S jjrg)    N)Callable	Coroutine)partial)TYPE_CHECKINGAnyLiteralTypeVaroverload)ResultAction)      )assert_neverAppVcommandboundbackend)asynciotrioc                    [         R                  " U 5      (       d&  Uc  U " 5       $ U " UR                  0 UR                  D6$ US:X  aH  SSKnUc  UR                  U " 5       5      $ UR                  U " UR                  0 UR                  D65      $ US:X  aJ  SSKnUc  UR                  U 5      $ UR                  [        U /UR                  Q70 UR                  D65      $ [        U5        g)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        G/home/james-whalen/.local/lib/python3.13/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                   g N r    r!   s     r   r   r   F   s    orr   c                   g r%   r&   r'   s     r   r   r   J   s    X[r   r!   c                   g r%   r&   r'   s     r   r   r   N   s     r   c                   g r%   r&   r'   s     r   r   r   T   s    _br   c               b    [         c  SSKJ n  Uq [        US9nUR                  U 5        U" 5       $ )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   