mihirkatare / DeepMEM

Deep Learning Implementations for Sustainable Matrix Element Method Calculations [ IRIS-HEP Fellowship ]
Apache License 2.0
2 stars 0 forks source link

Add CLI API using Click or Typer #20

Open matthewfeickert opened 3 years ago

matthewfeickert commented 3 years ago

At the moment I've just setup console scripts

https://github.com/mihirkatare/DeepMEM/blob/e3b233463ca448d3c3d0c3a6ff0b6501bac18c1b/setup.cfg#L45-L51

to link the old

if __name__ == "__main__"

behavior into shell scripts essentially. e.g.

https://github.com/mihirkatare/DeepMEM/blob/e3b233463ca448d3c3d0c3a6ff0b6501bac18c1b/setup.cfg#L45-L47

generates

(venv) user@machine $ command -v deepmem
/venv/bin/deepmem
(venv) user@machine $ cat $(command -v deepmem)
#!/venv/bin/python
# -*- coding: utf-8 -*-
import re
import sys
from deepmem._main import _main
if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
    sys.exit(_main())

which means running deepmem at the command line is really calling

https://github.com/mihirkatare/DeepMEM/blob/e3b233463ca448d3c3d0c3a6ff0b6501bac18c1b/src/deepmem/_main.py#L11

It would be good to turn this into a real CLI API though using Click or Typer.