Is there a way to create a .ipynb from a .py file command line?

I believe it is covered here: https://stackoverflow.com/a/23292713/3025981. I reproduce the snipped here:

import IPython.nbformat.current as nbf
nb = nbf.read(open('test.py', 'r'), 'py')
nbf.write(nb, open('test.ipynb', 'w'), 'ipynb')

From https://pypi.org/project/ipynb-py-convert/

pip install ipynb-py-convert

Example

ipynb-py-convert examples/plot.py examples/plot.ipynb

or

ipynb-py-convert examples/plot.ipynb examples/plot.py