
    Vi>K                     @   S SK r S SKrS SKrS SKrS SKJrJr  S SKJrJ	r	J
r
Jr  S SKJr  \" SSSSS	9rS
rS rS rS r\4S jrS rS rS\S4S jr0 SS_SS_SS_SS_SS_SS_SS _S!S_S"S
_S#S$_S%\
_S&\_S'\	_S(S)_S*S+_S,S_S-S_r " S. S/\5      r  " S0 S1\5      rg)2    N)uniquesplit)format_flag_labelformat_flag_post_docformat_posargs_labelecho)Flagz--helpTz-hzshow this help message and exit)parse_aschardocx   c                      SS K n SS Kn[        R                  " S/ SQ5      nU R                  [        R
                  UR                  U5      (       a   eUu  p4  nX44$ )Nr   H)r   r   r   r   )fcntltermiosarrayioctlsysstdout
TIOCGWINSZ)r   r   winsizews_rowws_col_s         _/home/james-whalen/.local/share/pipx/venvs/semgrep/lib/python3.13/site-packages/face/helpers.py_get_termios_winsizer      sO    kk#|,G{{3::w'9'97CCCC"FAq>    c                       [        [        R                  S   5      [        [        R                  S   5      pX4$ ! [        [        4 a	    Su  p X4$ f = f)NROWSCOLUMNSNN)intosenvironKeyError
ValueError)rowscolumnss     r   _get_environ_winsizer)      s[    #BJJv./RZZ	5J1Kg = j! #"g=#s   7< AAc                      Su  p [        5       u  pX4$ ! [         a%     [        5       u  p X4$ ! [         a      X4$ f = ff = f)Nr!   )r   	Exceptionr)   )r'   colss     r   get_winsizer-   (   sj    JD)+
 :  	-/JD$ :  	:	s"    
A0
A AA  Ac                 H    [        5       u  pUc  Sn[        X 5      nUS-  nU$ )NP      )r-   min)	max_widthr   widths      r   get_wrap_widthr4   4   s-    }HA}!E	QJELr   c                 x   / nUR                   nX-   nU(       d
  U" U5        U$ [        U5      n	[        R                  " X55      n
[        U5      U::  a.  UR	                  U[        U5      -
  5      U-   nU" XS   -   5        OU" U5        U" SXI-
  -  U-   U
S   -   5        U
SS   H  nU" SU-  U-   5        M     U$ )Nr       )appendlentextwrapwrapljust)indentlabelsepr   	doc_startmax_doc_widthretr8   lhslen_sepwrapped_doclhs_flines                r   _wrap_stout_pairrH   =   s    
 CZZF
.Cs
#hG--3K
3x9		)c#h./#5u1~%&sy*+s2[^CDABsY%&   Jr   c                 2   / n[        UR                  5       S 5       Vs/ s H  nU(       d  M  SR                  U5      PM     nnU H7  n[        R                  " UU[        U 5      -
  U U S9nUR                  U5        M9     SR                  U5      $ s  snf )z*Function for wrapping command description.c                 ,    U R                  5       (       + $ )N)lstrip)ls    r   <lambda>%_wrap_stout_cmd_doc.<locals>.<lambda>]   s    188:~r   
)textr3   initial_indentsubsequent_indentz

)r   
splitlinesjoinr:   fillr9   r8   )r=   r   r2   partsparaparasparts          r   _wrap_stout_cmd_docrZ   Y   s    E3>>#%=>> "& TYYt_> 
  }}$$-F$;,2/57 	T  ;;us
   BB(   c                     U=(       d	    [        US9n[        U5      n[        U5      nSnUn	X5-
  n
U  H8  n[        U5      nX:  a  M  UnX|-   U-   U-   U:  d  M'  X8-
  U-
  U-
  n	X|-   U-   n
M:     UUU	U
S.$ )Nr2   r   )r3   label_width	doc_widthr@   )r4   r9   )labelsr=   r?   r3   r2   min_doc_widthrD   
len_indentmax_label_widthrA   r@   r>   cur_lens                r   get_stout_layoutre   h   s    8^i8E#hGVJO!M%Ie*$! 7*]:eC!3g=
JM",w6I  *&"$ $r   usage_labelzUsage:subcmd_section_headingzSubcommands: flags_section_headingzFlags: posargs_section_headingzPositional arguments:section_breakrO   group_break subcmd_example
subcommandr3   r2   ra   2   r   r   r   doc_separatorz   section_indentz  pre_docpost_docc                   H    \ rS rSrSr\" \5      rS rS r	S	S jr
S	S jrSrg)
StoutHelpFormatter   a  This formatter takes :class:`Parser` and :class:`Command` instances
and generates help text. The output style is inspired by, but not
the same as, argparse's automatic help formatting.

Probably what most Pythonists expect, this help text is slightly
stouter (conservative with vertical space) than other conventional
help messages.

The default output looks like::

    Usage: example.py subcommand [FLAGS]

    Does a bit of busy work


    Subcommands:

      sum        Just a lil fun in the sum
      subtract
      print


    Flags:

      --help / -h               show this help message and exit
      --verbose / -V


Due to customizability, the constructor takes a large number of
keyword arguments, the most important of which are highlighted
here.

Args:
   width (int): The width of the help output in
      columns/characters. Defaults to the width of the terminal,
      with a max of *max_width*.
   max_width (int): The widest the help output will get. Too wide
      and it can be hard to visually scan. Defaults to 120 columns.
   min_doc_width (int): The text documentation's minimum width in
      columns/characters. Puts flags and subcommands on their own
      lines when they're long or the terminal is narrow. Defaults to
      50.
   doc_separator (str): The string to put between a
      flag/subcommand and its documentation. Defaults to `' '`. (Try
      `' + '` for a classy bulleted doc style.

An instance of StoutHelpFormatter can be passed to
:class:`HelpHandler`, which can in turn be passed to
:class:`Command` for maximum command customizability.

Alternatively, when using :class:`Parser` object directly, you can
instantiate this type and pass a :class:`Parser` object to
:meth:`get_help_text()` or :meth:`get_usage_line()` to get
identically formatted text without sacrificing flow control.

HelpFormatters are stateless, in that they can be used more than
once, with different Parsers and Commands without needing to be
recreated or otherwise reset.

c                     0 U l         U R                  R                  5        H#  u  p#UR                  X#5      U R                   U'   M%     U(       a%  [	        S[        UR                  5       5      -  5      eg )Nz"unexpected formatter arguments: %r)ctxdefault_contextitemspop	TypeErrorlistkeys)selfkwargskeyvals       r   __init__StoutHelpFormatter.__init__   s^    ,,224HC"JJs0DHHSM 5@4CVVWW r   c           	      T    U R                   n[        UUS   US   US   US   US   S9$ )Nrq   rp   r3   r2   ra   )r`   r=   r?   r3   r2   ra   )rx   re   )r   r`   rx   s      r   _get_layoutStoutHelpFormatter._get_layout   sD    hhv'*+;'<$'$8&)'l*-k*:.1/.BD 	Dr   Nc           
         U R                   nU R                  XUS9/nUR                  nU" US   5        UR                  USS9nU(       a  UR                  U   nUR
                  (       a?  U" [        US   UR
                  US   =(       d    [        US   S9S	95        U" US
   5        UR                  (       a  [        UR                   Vs/ s H  o(       d  M  US   PM     sn5      n	U R                  U	S9n
U" US   5        U" US   5        [        UR                   Vs/ s H  o(       d  M  US   PM     sn5       HX  nUR                  U4   n[        US   UR                  SS5      US   UR
                  U
S   U
S   S9nUR                  U5        MZ     U" US
   5        U(       d  SR                  U5      $ US   nU Vs/ s H
  o" U5      PM     nnU R                  US9nUS   nU" US   5        U" US   5        U H  nUR                  nUR                  b  UR                  nOnUR
                  (       a  UR
                  /O/ nUR                   (       a  UR                   OU" U5      nU(       a  UR                  U5        SR                  U5      n[        US   U" U5      US   UUS   US   S9nUR                  U5        M     US   SR                  U5      -   US   -   $ s  snf s  snf s  snf )a`  Turn a :class:`Parser` or :class:`Command` into a multiline
formatted help string, suitable for printing. Includes the
usage line and trailing newline by default.

Args:
   parser (Parser): A :class:`Parser` or :class:`Command`
      object to generate help text for.
   subcmds (tuple): A sequence of subcommand strings
      specifying the subcommand to generate help text for.
      Defaults to ``()``.
   program_name (str): The program name, if it differs from
      the default ``sys.argv[0]``. (For example,
      ``example.py``, when running the command ``python
      example.py --flag val arg``.)

subcmdsprogram_namerk   F)pathwith_hiddenrq   r3   r2   r]   )r=   r   r2   rj   r   )r`   rg   r   -rp   r@   r_   )r=   r>   r?   r   r@   rA   rO   r   r   rh   r6   rr   rs   )rx   get_usage_liner8   	get_flags
subprs_mapr   rZ   r4   r   r   rH   replaceextendrT   displayfull_docrs   )r   parserr   r   rx   rB   r8   shown_flagsspsubcmd_namessubcmd_layoutsub_namesubprssubcmd_linesfmt_flag_labelflagflag_labelsflag_layoutfmt_flag_post_docdispr   _partsrs   
flag_liness                           r   get_help_text StoutHelpFormatter.get_help_text   s   $ hh""6"VWs=!"&&G&G&&w/F::&c2B.C+1::14W 2G585EBGH I 3'(!63D3D"K3DR52a53D"KLL ,,L,AM3/013}%&"F4E4E#L4EbEBqE4E#LM**H;7/s;K7L6>6F6FsC6P474H4:JJ:G:T>KK>X Z 

<( N 3'(99S>!018CD~d+D&&k&: 67s*+,s=!"D<<D}}(mm'+xx$((R,0MM4==?PQU?VMM(+hhv&)5E1F0>t0D.1/.B.14?4L8CK8PRJ JJz"%  ( 9~		#.Z@@a #L
 $M" Es   
K3	K3%
K83	K8K=c                    U R                   n[        U=(       d    S5      nUS   (       a  US   /O/ nUR                  nU=(       d    UR                  nU" SR	                  U4U-   5      5        U(       d  UR
                  (       a	  U" S5        O-U(       a&  UR
                  U   R
                  (       a  U" S5        U(       a  UR
                  U   nUR                  SS9nU(       a  U" S5        UR                  R                  R                  (       d  US   nU" U" UR                  5      5        SR	                  U5      $ )	zGet just the top line of automated text output. Arguments are the
same as :meth:`get_help_text()`. Basic info about running the
command, such as:

   Usage: example.py subcommand [FLAGS] [args ...]

 rf   r6   rn   F)r   z[FLAGS]r   )
rx   tupler8   namerT   r   r   posargsr   hidden)	r   r   r   r   rx   rV   r8   flagsfmt_posargs_labels	            r   r   !StoutHelpFormatter.get_usage_line;  s    hh2&(+M(:]#$#2v{{sxx'123 6,,< **73>><  &&w/F  U 39~~%%,, #$: ;$V^^45xxr   )rx   )r   N)__name__
__module____qualname____firstlineno____doc__dictDEFAULT_CONTEXTry   r   r   r   r   __static_attributes__r   r   r   ru   ru      s-    ;x ?+OXDTAl$r   ru   c                   0    \ rS rSrSr\S\S4S jrS rSr	g)HelpHandlerim  a  The HelpHandler is a one-stop object for that all-important CLI
feature: automatic help generation. It ties together the actual
help handler with the optional flag and subcommand such that it
can be added to any :class:`Command` instance.

The :class:`Command` creates a HelpHandler instance by default,
and its constructor also accepts an instance of this type to
customize a variety of helpful features.

Args:
   flag (face.Flag): The Flag instance to use for triggering a
      help output in a Command setting. Defaults to the standard
      ``--help / -h`` flag. Pass ``False`` to disable.
   subcmd (str): A subcommand name to be added to any
      :class:`Command` using this HelpHandler. Defaults to
      ``None``.
   formatter: A help formatter instance or type. Type will be
      instantiated with keyword arguments passed to this
      constructor. Defaults to :class:`StoutHelpFormatter`.
   func (callable): The actual handler function called on flag
      presence or subcommand invocation. Defaults to
      :meth:`HelpHandler.default_help_func()`.

All other remaining keyword arguments are used to construct the
HelpFormatter, if *formatter* is a type (as is the default). For
an example of a formatter, see :class:`StoutHelpFormatter`, the
default help formatter.
Nc                    Xl         X l        Ub  UOU R                  U l        [	        U R                  5      (       d  [        SU-  5      eX0l        U(       d  [        SU-  5      e[        U[        5      (       a  U" S0 UD6U l        O1U(       a*  [        S[        UR                  5       5      < SU< 35      e[	        [        U R                  SS 5      5      nU(       d  [        SU R                  < 35      eg )Nz1expected help handler func to be callable, not %rz,expected Formatter type or instance, not: %rz%only accepts extra formatter kwargs (z2) if formatter argument is a Formatter type, not: r   zMexpected valid formatter, or other object with a get_help_text() method, not r   )r   subcmddefault_help_funcfunccallabler|   	formatter
isinstancetypesortedr~   getattr)r   r   r   r   r   formatter_kwargs_has_get_help_texts          r   r   HelpHandler.__init__  s     	 ,D$2H2H			""ORVVWW"JYVWWi&&&:)9:DN%&6&;&;&=>	K L L &gdnnot&TU!AER S Sr   c                 J    [        U R                  R                  XBUS95        g)zThe default help handler function. Called when either the help flag
or subcommand is passed.

Prints the output of the help formatter instance attached to
this HelpHandler and exits with exit code 0.

r   N)r   r   r   )r   cmd_subcmds_args_command_s        r   r   HelpHandler.default_help_func  s!     	T^^))(SW)XYr   )r   r   r   r   )
r   r   r   r   r   DEFAULT_HELP_FLAGru   r   r   r   r   r   r   r   r   m  s    @ .d-D0Zr   r   )r#   r   r   r:   boltons.iterutilsr   r   
face.utilsr   r   r   r   face.parserr	   r   DEFAULT_MAX_WIDTHr   r)   r-   r4   rH   rZ   re   r   objectru   r   r   r   r   <module>r      sf   	 
   + Z Z DtAbc  	 / 8 15@Q#%$28o Y 6	
 T 2 l T  R 0 * 0 U d  r!" #*I IZAZ& AZHzr   