TR2X/tools/generate_version
Marcin Kurczewski 73da1d8568
initial commit
2023-10-01 13:24:43 +02:00

27 lines
596 B
Python

#!/usr/bin/env python3
import argparse
from pathlib import Path
from subprocess import run
def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser()
parser.add_argument("-o", "--output", type=Path)
return parser.parse_args()
def generate_version() -> str:
cmd = ["git", "describe", "--abbrev=7", "--tags"]
version = run(cmd, capture_output=True, text=True).stdout
return f'TR2X {version or "?"}'
def main() -> None:
args = parse_args()
version = generate_version()
args.output.write_text(version)
if __name__ == "__main__":
main()