nB d Z ddlZddlZddlmZmZmZ ddlmZ ddl m
Z
dej defd Z
dej ddfd
Zdej defdZdej defdZdej fd
Zdej defdZddeee defdZdS )ac
CLI parsing for :command:`pysemver` command.
Each command in :command:`pysemver` is mapped to a ``cmd_`` function.
The :func:`main ` function calls
:func:`createparser ` and
:func:`process ` to parse and process
all the commandline options.
The result of each command is printed on stdout.
N)castListOptional )Version)__version__argsreturnc dddddd}| j | j dd g t j | j }t
||t t | j }t | S )
z
Subcommand: Bumps a version.
Synopsis: bump
can be major, minor, patch, prerelease, or build
:param args: The parsed arguments
:return: the new, bumped version
bump_major
bump_minor
bump_patchbump_prerelease
bump_build)majorminorpatch
prereleasebuildNbumpz-h) r parser
parse_argsr parseversiongetattrr str)r maptableverfuncs \/builddir/build/BUILD/cloudlinux-venv-1.0.10/venv/lib/python3.11/site-packages/semver/cli.pycmd_bumpr! s ' H y
~...
-
%
%C3c49!5!5677Dttvv;; c f t j | j rdS t d| j z )z
Subcommand: Checks if a string is a valid semver version.
Synopsis: check
:param args: The parsed arguments
NzInvalid version %r)r is_validr
ValueErrorr s r cmd_checkr' 1 s4 %% t
)DL8
9
99r" c t j | j }t | | j S )z
Subcommand: Compare two versions.
Synopsis: compare
:param args: The parsed arguments
)r r version1r compareversion2)r ver1s r cmd_comparer- > s1 =''Dt||DM**+++r" c t j | j }t | | j S )z
Subcommand: Determines the next version, taking prereleases into account.
Synopsis: nextver
:param args: The parsed arguments
)r r r r next_versionpart)r r s r cmd_nextverr1 J s3 mDL))Gw##DI..///r" c f t j t t } | dddt
z | }| dd }| t | d
d | dd
| dd }| t | dd }| dd | dd | dd | dd | dd fD ]}| dd | dd }| t | dd | d d! }| t | dd | d"d# | S )$z\
Create an :class:`argparse.ArgumentParser` instance.
:return: parser instance
)progdescriptionz --versionr z %(prog)s )actionr r* zCompare two versions)help)r r) z
First versionr+ zSecond versionr zBumps a versionz
Bump commands)titledestr 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 versionzVersion to raisecheckz,Checks if a string is a valid semver versionzVersion to checknextverz=Determines the next version, taking prereleases into account.r0 z1One of 'major', 'minor', 'patch', or 'prerelease')
argparseArgumentParser__package____doc__add_argumentr add_subparsers
add_parserset_defaultsr- r! r' r1 )r sparser_compareparser_bumpsbpparser_checkparser_nextvers r createparserrJ V s_
$+7
K
K
KF
I{[/H A\\)2H\IIN[111
AAA
1ABBB ,,v,=,>>K(+++ # #/ # G GB
g$H
II
g$H
II
g$H
II
l)R
SS
g$H
II ; ;
y'9:::: <<D L 9---i.@AAA \\W " N [111 0BCCCH Mr" c t | d s'| j t | | 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&