#!/usr/bin/env python3 import argparse import subprocess def run_process(*args): process = subprocess.run(args) return process.returncode == 0 def run_iteration(): if not run_process('cargo', 'build', '--release'): return False if not run_process('cargo', 'test', '--lib', '--quiet'): return False if not run_process('git', 'rebase', '--continue'): return False return True def parse_args(): parser = argparse.ArgumentParser() parser.add_argument('-l', '--loop', action='store_true', help='loop until failure') return parser.parse_args() def run_main(): settings = parse_args() if settings.loop: while run_iteration(): pass else: run_iteration() try: run_main() except KeyboardInterrupt: pass