mirror of
https://github.com/LostArtefacts/TR2X.git
synced 2024-11-23 13:59:45 +00:00
27 lines
596 B
Python
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()
|