Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature] Add a main script to print neuralprophet version #974

Merged
merged 8 commits into from
Dec 2, 2022
16 changes: 16 additions & 0 deletions neuralprophet/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
Invokes neuralprophet when module is run as a script.
"""
import argparse

from neuralprophet._version import __version__


def parse_args(args=None):
parser = argparse.ArgumentParser(description="NeuralProphet")
parser.add_argument("-v", "--version", action="version", version="%(prog)s " + __version__)
noxan marked this conversation as resolved.
Show resolved Hide resolved
noxan marked this conversation as resolved.
Show resolved Hide resolved
return parser.parse_args(args)


if __name__ == "__main__":
parse_args()
13 changes: 13 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import pytest

from neuralprophet.__main__ import parse_args
from neuralprophet._version import __version__


def test_main_file(capsys):
with pytest.raises(SystemExit) as exit_info:
parse_args(["--version"])

out, _ = capsys.readouterr()
assert exit_info.value.code == 0
assert __version__ in out