diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0a0f484..f52d9ae 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
## CHANGELOG
+### 1.6.0
+
+* Implement new option `--format-html`
+
### 1.5.0
* Implement new option `--format-rst`
diff --git a/README.md b/README.md
index 2d01701..f0dc8c4 100644
--- a/README.md
+++ b/README.md
@@ -18,6 +18,7 @@ Dump the software license list of Python packages installed with pip.
* [Option: order](#option-order)
* [Option: format\-markdown](#option-format-markdown)
* [Option: format\-rst](#option-format-rst)
+ * [Option: format\-html](#option-format-html)
* [More Information](#more-information)
* [License](#license)
* [Dependencies](#dependencies)
@@ -178,6 +179,31 @@ When executed with the `--format-rst` option, you can output list in "[Grid tabl
+--------+---------+---------+
```
+### Option: format-html
+
+When executed with the `--format-html` option, you can output list in HTML table format.
+
+```bash
+(venv) $ pip-licenses --format-html
+
+
+ Name |
+ Version |
+ License |
+
+
+ Django |
+ 2.0.2 |
+ BSD |
+
+
+ pytz |
+ 2017.3 |
+ MIT |
+
+
+```
+
### More Information
Other, please make sure to execute the `--help` option.
diff --git a/piplicenses.py b/piplicenses.py
index 8f001f3..e3772c2 100644
--- a/piplicenses.py
+++ b/piplicenses.py
@@ -38,7 +38,7 @@
from prettytable.prettytable import HEADER as RULE_HEADER, ALL as RULE_ALL
__pkgname__ = 'pip-licenses'
-__version__ = '1.5.0'
+__version__ = '1.6.0'
__author__ = 'raimon'
__license__ = 'MIT License'
__summary__ = ('Dump the software license list of '
@@ -188,6 +188,17 @@ def get_sortby(args):
return 'Name'
+def create_output_string(args):
+ table = create_licenses_table(args)
+ output_fields = get_output_fields(args)
+ sortby = get_sortby(args)
+
+ if args.format_html:
+ return table.get_html_string(fields=output_fields, sortby=sortby)
+ else:
+ return table.get_string(fields=output_fields, sortby=sortby)
+
+
def create_parser():
parser = argparse.ArgumentParser(
description=__summary__)
@@ -229,6 +240,10 @@ def create_parser():
action='store_true',
default=False,
help='dump as reST style')
+ parser.add_argument('--format-html',
+ action='store_true',
+ default=False,
+ help='dump as html style')
return parser
@@ -237,10 +252,8 @@ def main(): # pragma: no cover
parser = create_parser()
args = parser.parse_args()
- table = create_licenses_table(args)
- output_fields = get_output_fields(args)
- sortby = get_sortby(args)
- print(table.get_string(fields=output_fields, sortby=sortby))
+ output_string = create_output_string(args)
+ print(output_string)
if __name__ == '__main__': # pragma: no cover
diff --git a/test_piplicenses.py b/test_piplicenses.py
index 38b1010..7b58b31 100644
--- a/test_piplicenses.py
+++ b/test_piplicenses.py
@@ -8,7 +8,7 @@
from piplicenses import (__pkgname__, create_parser,
create_licenses_table, get_output_fields, get_sortby,
factory_styled_table_with_args,
- find_license_from_classifier,
+ find_license_from_classifier, create_output_string,
DEFAULT_OUTPUT_FIELDS, SYSTEM_PACKAGES,
LICENSE_UNKNOWN)
@@ -70,6 +70,9 @@ def test_with_empty_args(self):
sortby = get_sortby(args)
self.assertEquals('Name', sortby)
+ output_string = create_output_string(args)
+ self.assertNotIn('', output_string)
+
def test_from_classifier(self):
from_classifier_args = ['--from-classifier']
args = self.parser.parse_args(from_classifier_args)
@@ -192,5 +195,12 @@ def test_format_rst(self):
self.assertEquals('+', table.junction_char)
self.assertEquals(RULE_ALL, table.hrules)
+ def test_format_html(self):
+ format_html_args = ['--format-html']
+ args = self.parser.parse_args(format_html_args)
+ output_string = create_output_string(args)
+
+ self.assertIn('', output_string)
+
def tearDown(self):
pass