import sys, os import subprocess as xsub import time from typing import List def git_save(target_dir: str): retls = xsub.run("git status", shell=True, capture_output=True) outlist = str(retls.stdout).split(r'\n') has_changed:bool = False files_path:List[str] = [] for o in outlist: modified_flag = r"\tmodified:" new_flag = r"\tnew file:" delete_flag = r"\tdeleted:" if o.startswith(modified_flag): has_changed = True files_path.append(o[len(modified_flag):]) elif o.startswith(new_flag): has_changed = True files_path.append(o[len(new_flag):]) elif o.startswith(delete_flag): has_changed = True files_path.append(o[len(delete_flag):]) if has_changed: xsub.run(f"git add {" ".join(files_path)}", shell=True) xsub.run(f"git commit -m 'save-at:{time.time()}'") def nsc_compile(target_dir: str): retls = xsub.run("nsc --path ./ --dest E:/", shell=True) if __name__ == "__main__": print(sys.argv) cmd_line = ":".join(sys.argv[1:]) #wnss:-cmp if cmd_line == "wnss:-cmp": git_save(os.getcwd()) nsc_compile(os.getcwd())