1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-06-17 00:07:37 +02:00
Files
jc/docs/parsers/semver.md

82 lines
1.7 KiB
Markdown
Raw Permalink Normal View History

2022-11-04 16:03:39 -07:00
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.semver"></a>
# jc.parsers.semver
jc - JSON Convert Semantic Version string parser
This parser conforms to the specification at https://semver.org/
2023-02-27 17:37:49 -08:00
See Also: `ver` parser.
2022-11-04 16:03:39 -07:00
Usage (cli):
$ echo 1.2.3-rc.1+44837 | jc --semver
Usage (module):
import jc
result = jc.parse('semver', semver_string)
Schema:
Strings that do not strictly conform to the specification will return an
empty object.
{
"major": integer,
"minor": integer,
"patch": integer,
"prerelease": string/null,
"build": string/null
}
Examples:
$ echo 1.2.3-rc.1+44837 | jc --semver -p
{
"major": 1,
"minor": 2,
"patch": 3,
"prerelease": "rc.1",
"build": "44837"
}
$ echo 1.2.3-rc.1+44837 | jc --semver -p -r
{
"major": "1",
"minor": "2",
"patch": "3",
"prerelease": "rc.1",
"build": "44837"
}
<a id="jc.parsers.semver.parse"></a>
### parse
```python
2024-03-14 22:46:52 -07:00
def parse(data: str, raw: bool = False, quiet: bool = False) -> Dict[str, Any]
2022-11-04 16:03:39 -07:00
```
Main text parsing function
Parameters:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
Dictionary. Raw or processed structured data.
### Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
2023-12-21 14:55:21 -08:00
Source: [`jc/parsers/semver.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/semver.py)
2024-01-03 15:57:08 -08:00
This parser can be used with the `--slurp` command-line option.
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)