From 618125366999a908e7e86b6c79e61473e425c24c Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Wed, 14 Oct 2020 18:12:11 +0100 Subject: [PATCH] Assure ansi2html can be called as script or module --- ansi2html/__main__.py | 4 ++++ setup.cfg | 4 ++++ tests/test_ansi2html.py | 9 +++++++++ 3 files changed, 17 insertions(+) create mode 100644 ansi2html/__main__.py diff --git a/ansi2html/__main__.py b/ansi2html/__main__.py new file mode 100644 index 0000000..4cbddc4 --- /dev/null +++ b/ansi2html/__main__.py @@ -0,0 +1,4 @@ +from ansi2html.converter import main + +if __name__ == "__main__": + main() diff --git a/setup.cfg b/setup.cfg index c859710..7ea4089 100644 --- a/setup.cfg +++ b/setup.cfg @@ -39,6 +39,10 @@ setup_requires = setuptools_scm >= 1.15.0 setuptools_scm_git_archive >= 1.0 +[options.entry_points] +console_scripts = + ansi2html = ansi2html.__main__:main + [options.packages.find] where = . diff --git a/tests/test_ansi2html.py b/tests/test_ansi2html.py index 7d9d25f..5329266 100644 --- a/tests/test_ansi2html.py +++ b/tests/test_ansi2html.py @@ -25,6 +25,7 @@ import unittest from io import StringIO from os.path import abspath, dirname, join +from subprocess import run from mock import patch @@ -385,6 +386,14 @@ def test_latex_linkify(self): latex = Ansi2HTMLConverter(latex=True, inline=True, linkify=True).convert(ansi) assert target in latex + def test_command_script(self): + result = run(["ansi2html", "--version"], check=True) + assert result.returncode == 0 + + def test_command_module(self): + result = run(["python3", "-m", "ansi2html", "--version"], check=True) + assert result.returncode == 0 + if __name__ == "__main__": unittest.main()