TRX/scripts/generate_version

33 lines
889 B
Text
Raw Normal View History

2021-11-12 21:26:26 +01:00
#!/usr/bin/env python3
import argparse
from pathlib import Path
REPO_DIR = Path(__file__).parent.parent
2021-12-07 18:19:14 +01:00
SCRIPTS_BIN_DIR = REPO_DIR / "scripts" / "bin"
2021-11-12 21:26:26 +01:00
SRC_DIR = REPO_DIR / "src"
def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser()
parser.add_argument("--version")
2021-12-07 18:19:14 +01:00
parser.add_argument("--output", type=Path, nargs="+")
2021-11-12 21:26:26 +01:00
return parser.parse_args()
2021-12-07 18:19:14 +01:00
def write_rc_template(output_path: Path, args: argparse.Namespace) -> None:
input_path = SCRIPTS_BIN_DIR / output_path.name
template = input_path.read_text()
template = template.replace("{version}", args.version)
template = template.replace("{icon_path}", str(SCRIPTS_BIN_DIR / "icon.ico"))
output_path.write_text(template)
2021-11-12 21:26:26 +01:00
def main() -> None:
args = parse_args()
2021-12-07 18:19:14 +01:00
for output in args.output:
write_rc_template(output, args)
2021-11-12 21:26:26 +01:00
if __name__ == "__main__":
main()