discord test stars

About

The semantic versioning package in the Mys programming language.

Project: https://github.com/mys-lang/package-semver

Application

The semver application can increment version numbers as seen below.

 mys install semver
...
 Building (0.28 seconds)
 Installing semver in /Users/erik/.local/bin (0 seconds)
 semver increment major 2.1.3
3.0.0
 semver increment minor 2.1.3-rc4
2.2.0

Example

An application comparing two versions:

from semver import Version
from argparse import Parser

func main(argv: [string]):
    parser = Parser("compare")
    parser.add_positional("version-1")
    parser.add_positional("version-2")
    args = parser.parse(argv)

    version_1 = Version(args.value_of("version-1"))
    version_2 = Version(args.value_of("version-2"))

    if version_1 > version_2:
        print(f"{version_1} is newer than {version_2}.")
    elif version_1 == version_2:
        print(f"{version_1} and {version_2} are the same.")
    else:
        print(f"{version_2} is newer than {version_1}.")

Build and run:

 mys run -- 1.0.0 2.0.0
 Reading package configuration (0 seconds)
 Building (0.01 seconds)
2.0.0 is newer than 1.0.0.

API

class SemVerError(Error):
    message: string
class PreRelease:
    A semantic version pre-release.

    func __init__(self, value: string):
        Initialize a pre-release object from given string `value`.

        Raises SemVerError if `value` is not a valid semantic version
        pre-release.

    func identifiers(self) -> [string]:
        Returns the idenetifiers (dot separated values). For example, the
        pre-release "alpha.1" has two identifiers, "alpha" and "1".

    func ==(self, other: PreRelease) -> bool:

    func !=(self, other: PreRelease) -> bool:

    func <(self, other: PreRelease) -> bool:

    func >(self, other: PreRelease) -> bool:

    func <=(self, other: PreRelease) -> bool:

    func >=(self, other: PreRelease) -> bool:
class BuildMetadata:
    A semantic version build metadata.

    func __init__(self, value: string):
        Initialize a build metadata object from given string `value`.

        Raises SemVerError if `value` is not a valid semantic version
        build metadata.
class Version:
    A semantic version.

    major: i64
    minor: i64
    patch: i64
    pre_release: PreRelease?
    build_metadata: BuildMetadata?

    func __init__(self, version: string):
        Initialize a version object from given string `version`.

        Raises SemVerError if `version` is not a valid semantic
        version.

    func increment_major(self):
        Increment major by one. Reset pre-release, build metadata, minor
        and patch.

    func increment_minor(self):
        Increment minor by one. Reset pre-release, build metadata and
        patch.

    func increment_patch(self):
        Increment patch by one. Reset pre-release and build metadata.

    func ==(self, other: Version) -> bool:

    func !=(self, other: Version) -> bool:

    func <(self, other: Version) -> bool:

    func >(self, other: Version) -> bool:

    func <=(self, other: Version) -> bool:

    func >=(self, other: Version) -> bool: