90 lines
2.4 KiB
Python
90 lines
2.4 KiB
Python
"""
|
|
Vhex package cloning user interface
|
|
"""
|
|
import os
|
|
import sys
|
|
|
|
from core.logger import log
|
|
import core.pkg
|
|
|
|
|
|
__all__ = [
|
|
'pkg_clone_cli_parse'
|
|
]
|
|
|
|
|
|
__HELP__ = r"""
|
|
vxsdk-pkg-clone
|
|
Package manager cloning part
|
|
|
|
USAGE:
|
|
vxsdk pkg clone [ OPTIONS ] [ targets[, ...]]
|
|
|
|
DESCRIPTION:
|
|
The installation part is simple, you juste need to refer the repository
|
|
name and, optionally, the version information. Like this:
|
|
|
|
<NAME@version> (ex: vxKernel@1.2.3)
|
|
|
|
This will allow the searching to try to match package with specific version
|
|
information. This part is very powerfull because If the 'version' is
|
|
detected to respect the correct semantic versioning, you can perform version
|
|
operations in the version target:
|
|
|
|
Caret requirements (^)
|
|
^1.2.3 := >=1.2.3, <2.0.0
|
|
^1.2 := >=1.2.0, <2.0.0
|
|
^1 := >=1.0.0, <2.0.0
|
|
^0.2.3 := >=0.2.3, <0.3.0
|
|
^0.2 := >=0.2.0, <0.3.0
|
|
^0.0.3 := >=0.0.3, <0.0.4
|
|
^0.0 := >=0.0.0, <0.1.0
|
|
^0 := >=0.0.0, <1.0.0
|
|
|
|
Tilde requirements (~)
|
|
~1.2.3 := >=1.2.3, <1.3.0
|
|
~1.2 := >=1.2.0, <1.3.0
|
|
~1 := >=1.0.0, <2.0.0
|
|
|
|
Wildcard requirements (*)
|
|
* := >=0.0.0
|
|
1.* := >=1.0.0, <2.0.0
|
|
1.2.* := >=1.2.0, <1.3.0
|
|
|
|
Note that it's possible that a package can have two same version (one for
|
|
branch name and another for a tag), by default, the tag is always selected,
|
|
but here the display information will explicitly describe if the version is
|
|
a tag and / or a branch.
|
|
|
|
OPTIONS:
|
|
-y, --yes Do not ask for interactive confirmation
|
|
-n, --no-build Do not build the project, just clone
|
|
-h, --help Print this help and exit
|
|
""".strip()
|
|
|
|
#---
|
|
# Entry point of the module
|
|
#---
|
|
|
|
def pkg_clone_cli_parse(argv):
|
|
""" Clone a particular package """
|
|
if not argv:
|
|
log.error(__HELP__)
|
|
sys.exit(84)
|
|
if '-h' in argv or '--help' in argv:
|
|
log.user(__HELP__)
|
|
sys.exit(0)
|
|
|
|
confirm = True
|
|
for arg in argv:
|
|
if arg in ['-y', '--yes', '-c', '--confirm']:
|
|
confirm = arg in ['-c', '--confirm']
|
|
continue
|
|
core.pkg.clone(
|
|
arg.split('@')[0],
|
|
None if len(arg.split('@')) != 2 else arg.split('@')[1],
|
|
os.getcwd(),
|
|
confirm
|
|
)
|
|
return 0
|