mirror of https://github.com/mingrammer/diagrams
This change addresses https://github.com/mingrammer/diagrams/issues/369 while providing a simple CLI entry point which can be used outside the virtual environment of the installed package. This works well with for example with [pipx](https://pipxproject.github.io/pipx/) or [uv](https://docs.astral.sh/uv/).pull/524/head
parent
95f1bbabe9
commit
4ea9103f65
@ -0,0 +1,31 @@
|
||||
import argparse
|
||||
import sys
|
||||
|
||||
|
||||
def run() -> int:
|
||||
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:
|
||||
print(path)
|
||||
with open(path) as f:
|
||||
exec(f.read())
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
def main():
|
||||
sys.exit(run())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Loading…
Reference in new issue