Replace validate arg with apply arg

This commit is contained in:
LilyRose2798 2024-04-20 20:24:38 +10:00
parent 0232ce9c44
commit 022398e275
1 changed files with 7 additions and 8 deletions

View File

@ -305,7 +305,7 @@ def main():
parser = ArgumentParser("woven")
parser.add_argument("-q", "--quiet", action = "store_true", help = "decrease output verbosity")
parser.add_argument("-c", "--config", default = "mesh-config.json", help = "the path to the config file")
parser.add_argument("-v", "--validate", action = "store_true", help = "only validate the config without applying it")
parser.add_argument("-a", "--apply", action = "store_true", help = "apply the configuration")
args = parser.parse_args()
with redirect_stdout(open(devnull, "w") if args.quiet else stdout):
@ -323,13 +323,12 @@ def main():
err_str = "\n".join(transform_error(e))
print(f"The following validation errors occurred when loading the configuration file:\n{err_str}", file = stderr)
exit(1)
if args.validate:
return
try:
config.apply()
except Exception as e:
print(f"error applying configuration: {e}", file = stderr)
exit(1)
if args.apply:
try:
config.apply()
except Exception as e:
print(f"error applying configuration: {e}", file = stderr)
exit(1)
if __name__ == "__main__":
main()