mirror of https://github.com/mingrammer/diagrams
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
743 B
39 lines
743 B
import argparse
|
|
import sys
|
|
|
|
|
|
def run() -> int:
|
|
"""
|
|
Run diagrams code files in a diagrams environment.
|
|
Args:
|
|
paths: A list of paths to Python files containing diagrams code.
|
|
|
|
Returns:
|
|
The exit code.
|
|
"""
|
|
parser = argparse.ArgumentParser(
|
|
description="Run diagrams code files in a diagrams environment.",
|
|
)
|
|
parser.add_argument(
|
|
"paths",
|
|
metavar="path",
|
|
type=str,
|
|
nargs="+",
|
|
help="a Python file containing diagrams code",
|
|
)
|
|
args = parser.parse_args()
|
|
|
|
for path in args.paths:
|
|
with open(path, encoding='utf-8') as f:
|
|
exec(f.read())
|
|
|
|
return 0
|
|
|
|
|
|
def main():
|
|
sys.exit(run())
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|