diff --git a/README.rst b/README.rst index aa7bb04..66d722a 100644 --- a/README.rst +++ b/README.rst @@ -33,6 +33,7 @@ Features * Generated table can be provided some ``attributes`` explicitly. Eg. giving an ``id``, ``class`` or any ``data-*`` attribute. * Python 3 compatible +* Can be used as a library in your code base or called from command line Live Demo ---------- @@ -195,6 +196,18 @@ Output:
glossary
GlossDiv
GlossList
GlossEntry
GlossDef
GlossSeeAlso
  • GML
  • XML
paraA meta-markup language, used to create markup languages such as DocBook.
GlossSeemarkup
AcronymSGML
GlossTermStandard Generalized Markup Language
AbbrevISO 8879:1986
SortAsSGML
IDSGML
titleS
titleexample glossary
+**Example 6:** + +.. code-block:: bash + + echo '{"key":"value"}'|json2html + +Output: + +.. code-block:: bash + +
keyvalue
+ Tests ------ diff --git a/json2html/jsonconv.py b/json2html/jsonconv.py index 9ef8c73..fafb90b 100644 --- a/json2html/jsonconv.py +++ b/json2html/jsonconv.py @@ -174,3 +174,15 @@ def convert_object(self, json_input): return converted_output json2html = Json2Html() + +def main(): + import argparse + parser = argparse.ArgumentParser() + parser.add_argument('infile', nargs='?', type=argparse.FileType('r'), + default=sys.stdin) + args = parser.parse_args() + data = args.infile.read() + print(json2html.convert(json = data)) + +if __name__ == "__main__": + main() diff --git a/setup.py b/setup.py index 43b404a..b1d60dd 100644 --- a/setup.py +++ b/setup.py @@ -23,4 +23,7 @@ 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: Implementation :: CPython', ], + entry_points = { + 'console_scripts': ['json2html = json2html:main'] + } )