File: //home/arjun/projects/env/lib/python3.10/site-packages/click_repl/__pycache__/utils.cpython-310.pyc
o
%we� � @ s� d dl Z d dlZd dlZd dlZd dlmZ ddlmZmZ g d�Z ej
dkr0d dlmZm
Z
nd dlmZm
Z
d!dd �Zi Zd"dd�Zd!d
d�Zd!dd�Zdd� Zdd� Zeg d�ed� eg d�ed�
d#dd�Zdd� Zdd� Zdd � ZdS )$� N)�defaultdict� )�CommandLineParserError�ExitReplException)
�_execute_internal_and_sys_cmds�_exit_internal�_get_registered_target�_help_internal�_resolve_context�_register_internal_command�dispatch_repl_commands�handle_internal_commands�split_arg_string�exit)� r )�Iterable�Mappingc C s� | r^|j }t|tj�rY|js-|�|| �\}}} |du r|S |j|| |dd�}|j|j } n/| rN|�|| �\}}} |du r>|S |j|| |dddd�}|j} | s/|}g |j�|j�} n |S | s|S )a; Produce the context hierarchy starting with the command and
traversing the complete arguments. This only follows the commands,
it doesn't trigger input prompts or callbacks.
:param args: List of complete args before the incomplete value.
:param cli_ctx: `click.Context` object of the CLI group
NT)�parent�resilient_parsingF)r �allow_extra_args�allow_interspersed_argsr ) �command�
isinstance�click�MultiCommand�chain�resolve_command�make_context�protected_args�args)r �ctxr �name�cmd�sub_ctx� r$ �I/home/arjun/projects/env/lib/python3.10/site-packages/click_repl/utils.pyr
s: ���"r
Tc C sZ t j | |d�}d|_d|_g }z
|D ]}|�|� qW |S ty, |�|j� Y |S w )a� Split an argument string as with :func:`shlex.split`, but don't
fail if the string is incomplete. Ignores a missing closing quote or
incomplete escape sequence and uses the partial token as-is.
.. code-block:: python
split_arg_string("example 'my file")
["example", "my file"]
split_arg_string("example my\")
["example", "my"]
:param string: String to split.
)�posixT� )�shlex�whitespace_split�
commenters�append�
ValueError�token)�stringr&