diff --git a/html2text.py b/html2text.py
index ee2db9af..6db81a28 100644
--- a/html2text.py
+++ b/html2text.py
@@ -714,7 +714,7 @@ def html2text(html, baseurl=''):
h = HTML2Text(baseurl=baseurl)
return h.handle(html)
-if __name__ == "__main__":
+def main():
baseurl = ''
p = optparse.OptionParser('%prog [(filename|url) [encoding]]',
@@ -782,3 +782,7 @@ def html2text(html, baseurl=''):
h.hide_strikethrough = options.hide_strikethrough
wrapwrite(h.handle(data))
+
+
+if __name__ == "__main__":
+ main()
diff --git a/setup.py b/setup.py
index 2999bfdf..63b2541c 100644
--- a/setup.py
+++ b/setup.py
@@ -24,6 +24,10 @@
'Programming Language :: Python :: 3.1',
'Programming Language :: Python :: 3.2'
],
+ entry_points="""
+ [console_scripts]
+ html2text=html2text:main
+ """,
license='GNU GPL 3',
packages=find_packages(),
py_modules=['html2text'],