Crates.io | semverq |
lib.rs | semverq |
version | 0.1.0 |
source | src |
created_at | 2022-05-21 09:16:42.237633 |
updated_at | 2022-05-21 09:16:42.237633 |
description | a cli tool for accessing semver structure |
homepage | |
repository | https://github.com/eldesh/semverq |
max_upload_size | |
id | 590643 |
size | 17,661 |
Semverq is a cli utility for:
For -i
option, semverq validates the input string as a semver.
$ semverq -i '1.2.3-beta+dev-armhf'
(nothing is output)
$ echo $?
0
$ semverq -i '1.2.3-beta+dev+armhf'
invalid format as semver: 1.2.3-beta+dev+armhf
$ echo $?
150
If the -i
option is not specified, semverq reads string from standard input.
$ semverq <<<'1.2.3-input+stdin'
$ echo $?
0
For -j
option, semverq converts the input to json.
$ semverq -j -i '1.2.3-beta+36a1d2f'
{
"major": 1,
"minor": 2,
"patch": 3,
"pre-release": "beta",
"build": "36a1d2f"
}
If pre-release
or build
is not exists, the values of their fields will be null
.
$ semverq -j -i '1.2.3'
{
"major": 1,
"minor": 2,
"patch": 3,
"pre-release": null,
"build": null
}
For -q
option, access semver parts.
Get only major version:
$ semverq -q '.major' -i '1.2.3-beta+36a1d2f'
1
Build a json object with pre-release
and build
:
$ semverq -q '{ "pre-release": ".pre-release", "build": ".build" }' -i '1.2.3-beta+36a1d2f'
{ "pre-release": "beta", "build": "36a1d2f" }
Supported accessors are below:
.major
Major version..minor
Minor version..patch
Patch version..pre-release
or .pre
pre-release version..build
Build metadata..version-core
Shorthand for .major..minor..patch
.For -m
option, semverq checking for a match to given requirement.
The requirement is constructed from comma separated version constraint.
This matching syntax and rules are same as in Rust's package system.
Matching case:
$ semverq -m '>1.2.1, <=2.0.0' -i '1.2.3'
$ echo $?
0
Not matching case:
$ semverq -m '^1.2.1, 1.3.*' -i '1.2.3-beta+dev-armhf'
Version (1.2.3-beta+dev-armhf) does not match that requirement (^1.2.1, 1.3.*).
$ echo $?
152
Invalid requirement:
$ semverq -m '>1.2.1, <=2.0.0.' -i '1.2.3'
invalid format as version requirement: >1.2.1, <=2.0.0.
$ echo $?
151