YU 2 d Z ddlZddlZddlmZmZmZ dedefdZdej deeedf ee f fd Z dej dee fd Zdej deedf deeedf ee f fd Zdeeedf ee f deedf dee fdZ ddej dedefdZ ddej dedefdZ ddej dedefdZeeedZ ee Z ddej dededefdZdS )z Shell auto-completion script generators for the CLI. Introspects an argparse parser to enumerate all commands, subcommands, and flags, then emits completion scripts for bash, zsh, and fish. N)DictListTupleprogreturnc . t j dd| S )zDConvert a prog name to a safe shell identifier (letters, digits, _).z[^a-zA-Z0-9]_)resub)r s V/opt/imunify360/venv/lib/python3.11/site-packages/defence360agent/utils/completions.py_safe_identifierr s 6/3--- parser.c , i }t | d| |S )z@Walk the parser tree and return {command_path: [flags]} mapping. )_walk_parser)r results r _collect_commandsr s 02FV$$$Mr c g }| j D ]W}t |t j rt |t j r8|j D ]}| | Xt | S )z:Extract all optional flags from a parser (excluding help).)_actions isinstanceargparse_HelpAction_SubParsersActionoption_stringsappendsorted)r flagsactionopts r _get_flagsr! s E/ fh233 fh899 ( CLL %==r pathr c t | }|||<