#!/usr/bin/env python
"""
Script to generate string representations of system versions in the format [MAJOR].[MINOR].[PATCH]

Dependencies:
    None

Source used:
    https://semver.org/
"""
import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--major", type=int, action="store", dest="max_major", default=10, help="Maximum major version wanted. Default to 10.", required=False)
parser.add_argument("--minor", type=int, action="store", dest="max_minor", default=20, help="Maximum minor version wanted. Default to 20.", required=False)
parser.add_argument("--patch", type=int, action="store", dest="max_patch", default=20, help="Maximum patch version wanted. Default to 20.", required=False)
parser.add_argument("--output-file", action="store", dest="output_file", default="versions.txt", help="Output file. Default to 'versions.txt'.", required=False)
args = parser.parse_args()
content = []
for major in range(0, args.max_major + 1):
    for minor in range(0, args.max_minor + 1):
        if minor == 0:
            content.append(f"{major}")
        for patch in range(0, args.max_patch + 1):
            if patch == 0:
                content.append(f"{major}.{minor}")
            content.append(f"{major}.{minor}.{patch}")
with open(args.output_file, encoding="utf8", mode="w") as f:
    f.write("\n".join(content))
