
    \jE                     6   d Z ddlZddlZddlmZmZmZ ddlmZ ddl	m
Z
 dej                  defd	Zdej                  ddfd
Zdej                  defdZdej                  defdZdej"                  fdZdej                  defdZddeee      defdZy)ac  
CLI parsing for :command:`pysemver` command.

Each command in :command:`pysemver` is mapped to a ``cmd_`` function.
The :func:`main <semver.cli.main>` function calls
:func:`createparser <semver.cli.createparser>` and
:func:`process <semver.cli.process>` to parse and process
all the commandline options.

The result of each command is printed on stdout.
    N)castListOptional   )Version)__version__argsreturnc                    dddddd}| j                   | j                  j                  ddg       t        j                  | j
                        }t        ||t        t        | j                                  }t         |             S )	z
    Subcommand: Bumps a version.

    Synopsis: bump <PART> <VERSION>
    <PART> can be major, minor, patch, prerelease, or build

    :param args: The parsed arguments
    :return: the new, bumped version
    
bump_major
bump_minor
bump_patchbump_prerelease
bump_build)majorminorpatch
prereleasebuildbumpz-h)	r   parser
parse_argsr   parseversiongetattrr   str)r	   maptableverfuncs       4/root/env/lib/python3.12/site-packages/semver/cli.pycmd_bumpr!      sx     'H yy 	~.
--
%C3c499!567Dtv;    c                 r    t        j                  | j                        ryt        d| j                  z        )z
    Subcommand: Checks if a string is a valid semver version.

    Synopsis: check <VERSION>

    :param args: The parsed arguments
    NzInvalid version %r)r   is_validr   
ValueErrorr	   s    r    	cmd_checkr'   1   s.     %
)DLL8
99r"   c                     t        j                  | j                        }t        |j	                  | j
                              S )z
    Subcommand: Compare two versions.

    Synopsis: compare <VERSION1> <VERSION2>

    :param args: The parsed arguments
    )r   r   version1r   compareversion2)r	   ver1s     r    cmd_comparer-   >   s.     =='Dt||DMM*++r"   c                     t        j                  | j                        }t        |j	                  | j
                              S )z
    Subcommand: Determines the next version, taking prereleases into account.

    Synopsis: nextver <VERSION> <PART>

    :param args: The parsed arguments
    )r   r   r   r   next_versionpart)r	   r   s     r    cmd_nextverr1   J   s0     mmDLL)Gw##DII.//r"   c                     t        j                  t        t              } | j	                  dddt
        z          | j                         }|j                  dd      }|j                  t        	       |j	                  d
d       |j	                  dd       |j                  dd      }|j                  t        	       |j                  dd      }|j                  dd      |j                  dd      |j                  dd      |j                  dd      |j                  dd      fD ]  }|j	                  dd        |j                  dd      }|j                  t        	       |j	                  dd       |j                  d d!      }|j                  t        	       |j	                  dd       |j	                  d"d#       | S )$z\
    Create an :class:`argparse.ArgumentParser` instance.

    :return: parser instance
    )progdescriptionz	--versionr   z	%(prog)s )actionr   r*   zCompare two versions)help)r   r)   zFirst versionr+   zSecond versionr   zBumps a versionzBump commands)titledestr   z"Bump the major part of the versionr   z"Bump the minor part of the versionr   z"Bump the patch part of the versionr   z'Bump the prerelease part of the versionr   z"Bump the build part of the versionzVersion to raisecheckz,Checks if a string is a valid semver versionzVersion to checknextverz=Determines the next version, taking prereleases into account.r0   z1One of 'major', 'minor', 'patch', or 'prerelease')argparseArgumentParser__package____doc__add_argumentr   add_subparsers
add_parserset_defaultsr-   r!   r'   r1   )r   sparser_compareparser_bumpsbpparser_checkparser_nextvers           r    createparserrJ   V   s    $$+7KF
I{[/H   	A\\)2H\IN[1
A
1AB ,,v,=,>K(+		#	#/	#	GB 	g$HI
g$HI
g$HI
l)RS
g$HI ; 	
y'9:; <<D   L 9-i.@A \\W " N [1	0BCH    Mr"   c                     t        | d      s$| j                  j                          t               | j	                  |       S )z
    Process the input from the CLI.

    :param args: The parsed arguments
    :param parser: the parser instance
    :return: result of the selected action
    r   )hasattrr   
print_help
SystemExitr   r&   s    r    processrO      s6     4  l 99T?r"   cliargsc                     	 t               }|j                  |       }||_        t        |      }|t	        |       y# t
        t        f$ r&}t	        d|t        j                         Y d}~yd}~ww xY w)z
    Entry point for the application script.

    :param list cliargs: Arguments to parse or None (=use :class:`sys.argv`)
    :return: error code
    r&   Nr   ERROR)file   )	rJ   r   r   rO   printr%   	TypeErrorsysstderr)rP   r   r	   resulterrs        r    mainr[      si      g .&M	" gs,s   ;> A3A..A3)N)r>   r;   rW   typingr   r   r   r   r   	__about__r   	Namespacer   r!   r'   r-   r1   r<   rJ   rO   intr[    r"   r    <module>ra      s   
  
 ' '  "8%% # 8
:H&& 
:4 
:	,h(( 	,S 	,	0h(( 	0S 	02h-- 2j($$   (49%  r"   