#!/usr/bin/python3 -su

## Copyright (C) 2023 - 2025 ENCRYPTED SUPPORT LLC <adrelanos@whonix.org>
## See the file COPYING for copying conditions.

import sys

def bump_version(version):
    parts = list(map(int, version.split('.')))

    # If the last part is not 9, increment it and we're done.
    if parts[-1] < 9:
        parts[-1] += 1
    else:
        # If the last part is 9, we have to increment the next part.
        for i in range(len(parts) - 1, -1, -1):
            if parts[i] < 9:
                parts[i] += 1
                # Reset all parts after the one we just incremented.
                for j in range(i + 1, len(parts)):
                    parts[j] = 0
                break
            # If we reached the first part and it's 9, we increment it to 10
            # This is a simplistic handling and assumes no version part has a limit higher than 9
            if i == 0:
                parts[i] += 1
                for j in range(1, len(parts)):
                    parts[j] = 0

    return '.'.join(map(str, parts))

if __name__ == "__main__":
    if len(sys.argv) != 2:
        print("Usage: {} <version>".format(sys.argv[0]))
        sys.exit(1)

    version_input = sys.argv[1]
    bumped_version = bump_version(version_input)
    print(bumped_version)
