+
    Q(i"                     ~    R t ^ RIt^ RIt^ RIHt ^ RIHt ^ RIHtH	t	 ^ RI
Ht R R ltR R	 ltR
 R ltR R ltR# )zShell completion installation utilities.

This module handles the installation of completion scripts to shell-specific
locations and the updating of shell RC files to load completions.
N)CallablePath)	AnnotatedLiteral)	Parameterc                2    V ^8  d   QhR\         R,          /# )   returnNr   )formats   "a/Users/agent/.openclaw/workspace/venv/lib/python3.14/site-packages/cyclopts/completion/install.py__annotate__r      s      TD[     c                 \   \         P                  P                  R4      p V '       d+   \        V 4      pVP	                  4       '       d
   VR,          # \         P                  P                  R4      pV'       g   R# \        V4      pVP	                  4       '       d   VR,          R,          # R# )aY  Detect oh-my-zsh custom completions directory.

Uses ``$ZSH_CUSTOM/completions`` (the recommended location for user
completions in oh-my-zsh). Falls back to ``$ZSH/custom/completions``
when ``$ZSH_CUSTOM`` is not set.

Returns
-------
Path | None
    Path to the oh-my-zsh custom completions directory, or None if
    oh-my-zsh is not detected.

ZSH_CUSTOMcompletionsZSHNcustom)osenvirongetr   is_dir)zsh_custom_str
zsh_customzsh_dir_strzsh_dirs       r   _detect_omz_completions_dirr      s     ZZ^^L1N.)
--**..'K;G~~!M11r   c                J    V ^8  d   QhR\         R,          R\        R\        /# )r	   shell	prog_namer
   zshbashfish)r   strr   )r   s   "r   r   r   +   s)     '8 '8w/D'E '8RU '8Z^ '8r   c                   \         P                  ! 4       pV R8X  d]   \        4       pVe    VP                  RRR7       VRV 2,          # VR,          R,          pVP                  RRR7       VRV 2,          # V R8X  d:   VR,          R	,          R
,          R,          pVP                  RRR7       WQ,          # V R8X  d6   VR,          R,          R,          pVP                  RRR7       Wa R2,          # \	        RV  24      h)aC  Get the default completion script path for a given shell.

Parameters
----------
shell : Literal["zsh", "bash", "fish"]
    Shell type.
prog_name : str
    Program name for the completion script.

Returns
-------
Path
    Default installation path for the shell.

Raises
------
ValueError
    If shell type is unsupported.
r!   T)parentsexist_ok_z.zshr   r"   z.localsharezbash-completionr#   z.configz.fishzUnsupported shell: )r   homer   mkdir
ValueError)r   r   r*   omz_completionszsh_completionsbash_completionsfish_completionss   &&     r   get_default_completion_pathr1   +   s	   ( 99;D~57&!!$!>"q_44--7dT:1YK00	&(?W47HH=Xtd;++	&)+f4}Dtd;Ku"555.ug677r   c                V    V ^8  d   QhR\         R\        R\        R,          R\        /# )r	   script_pathr   r   r
   )r"   r!   )r   r$   r   bool)r   s   "r   r   r   U   s.     : : : :W]=S :X\ :r   c                :   VR8X  d-   \         P                  ! 4       R,          pRV  RV  R2pRV R2pMTVR8X  dH   \        4       '       d   R	# \         P                  ! 4       R
,          pV P                  pRV R2pRV R2pM\        hVP                  4       pVP                  4       '       dD   VP                  4       pVR8X  d$   \        V P                  4      V9   d
   RV9   d   R	# WG9   d   R	# MRpVR8X  d   VP                  V RV RV 24       R# T;'       d    VP                  R4      '       * pVP                  R4      ;_uu_ 4       p	V'       d   V	P                  R4       V	P                  V RV R24       RRR4       R#   + '       g   i     R# ; i)a  Add completion configuration to shell RC file.

For bash, adds a source line to load the completion script.
For zsh, adds the completion directory to fpath so compinit can find it.

Parameters
----------
script_path : Path
    Path to the completion script.
prog_name : str
    Program name for display in comments.
shell : Literal["bash", "zsh"]
    Shell type.

Returns
-------
bool
    True if configuration was added, False if it already existed or on error.
r"   .bashrcz[ -f "z
" ] && . ""z# Load z completionr!   F.zshrczfpath=( $fpath)z# z completionszfpath= 
aNT)r   r*   r   parentNotImplementedErrorresolveexists	read_textr$   
write_textendswithopenwrite)
r3   r   r   rc_fileconfig_linecommentcompletion_dircontentneeds_newlinefs
   &&&       r   add_to_rc_filerM   U   s   ( ))+	){m:k]!DI;k2	%&(())+($++/x8yk.!!ooG~~##% E>c+"4"45@XQXEX# $ ~gYbRyAB   >>(8(8(>$>\\#!GGwir+b12 
  
 s   1F		F	c                J    V ^8  d   QhR\         R\        3,          R\        /# )r	   install_completion_fn.add_to_startup)r   r   r4   )r   s   "r   r   r      s)     [' ['#CI.['['r   c                *   a a RRRR/R VV 3R lllpV# )a  Create a command function for installing shell completion.

Parameters
----------
install_completion_fn : Callable
    Function that performs the actual installation (typically App.install_completion).
    Should accept (shell, output, add_to_startup) and return the installation path.
add_to_startup : bool
    Whether to add source line to shell RC file.

Returns
-------
Callable
    Command function that can be registered with App.command().
r   Noutputc          	          V ^8  d   QhR\         \        R,          R,          \        4       3,          R\         \        R,          \        RR.R7      3,          /# )r	   r   NrR   z-oz--output)namer    )r   r   r   r   )r   s   "r   r   7create_install_completion_command.<locals>.__annotate__   sQ     E& E&!67$>	KLE& $+ytZ6H'IIJE&r   c                  < ^ RI HpHp V f	    V! 4       p S	! WSR7      p\        RV 24       V R8X  d   \        4       '       d   \        R4       \        R	4       R# S'       dR   \        P                  ! 4       R
,          pVP                  p\        RV RV 24       \        R4       \        R4       R# VP                  p\        RV R24       \        R4       \        RV R24       \        R4       \        R4       R# V R8X  d   S'       d8   \        P                  ! 4       R,          p\        RV 24       \        R4       R# \        R4       \        R4       \        R4       \        R4       \        R4       \        R4       \        R 4       \        R!4       R# V R"8X  d   \        R#4       \        R$4       R# \        h  T d6    \        R\        P
                  R7       \        P                  ! ^4        ELi ; i)%a  Install shell completion for this application.

This command generates and installs the completion script to the appropriate
location for your shell. After installation, you may need to restart your
shell or source your shell configuration file.

Parameters
----------
shell : Literal["zsh", "bash", "fish"] | None
    Shell type for completion. If not specified, attempts to auto-detect current shell.
output : Path | None
    Output path for the completion script. If not specified, uses shell-specific default.
)ShellDetectionErrordetect_shellNz?Could not auto-detect shell. Please specify --shell explicitly.)file)r   rR   rP   u#   ✓ Completion script installed to r!   uC   ✓ Detected oh-my-zsh: completions directory is already in $fpath.z$
Restart your shell or run: exec zshr8   u
   ✓ Added z to fpath in zX
Note: Ensure compinit is configured in your .zshrc (most zsh setups already have this).z#Restart your shell or run: exec zshz
To enable completions, ensure z is in your $fpath.z@Add this to your ~/.zshrc or ~/.zprofile if not already present:z    fpath=(r9   z%    autoload -Uz compinit && compinitz)
Then restart your shell or run: exec zshr"   r6   u   ✓ Added completion loader to z,
Restart your shell or run: source ~/.bashrcz=
Completions will be automatically loaded by bash-completion.zIf completions don't work:z0  1. Ensure bash-completion is installed (v2.8+)z)  2. Restart your shell or run: exec bashz2
Note: bash-completion is typically installed via:z)  - macOS: brew install bash-completion@2z.  - Debian/Ubuntu: apt install bash-completionz,  - Fedora/RHEL: dnf install bash-completionr#   z.
Completions are automatically loaded in fish.z<Restart your shell or run: source ~/.config/fish/config.fish)cyclopts.completion.detectrW   rX   printsysstderrexitr   r   r*   r=   r>   )
r   rR   rW   rX   install_pathzshrcrI   bashrcrP   rO   s
   $$      r   _install_completion_commandFcreate_install_completion_command.<locals>._install_completion_command   s   $ 	Q=$ -5Xfg3L>BCE>*,,[\=>		h.!-!4!4
>"2-wGHqr;<!-!4!488HH[\]XYN#38<==>BCf_y07x@AEFVW23HIABKLABFGDEf_CDPQ%%] ' U s   G 8HH )rO   rP   rb   s   ff r   !create_install_completion_commandre      s.    (E&OSE& NRE& E&N '&r   )__doc__r   r\   collections.abcr   pathlibr   typingr   r   cyclopts.parameterr   r   r1   rM   re   rd   r   r   <module>rk      s5    
 
 $  % (6'8T:z['r   