diff --git a/docs/parsers/csv.md b/docs/parsers/csv.md index 515e9614..ffbccbdc 100644 --- a/docs/parsers/csv.md +++ b/docs/parsers/csv.md @@ -4,8 +4,8 @@ jc - JSON CLI output utility `csv` file parser The `csv` parser will attempt to automatically detect the delimiter -character. If the delimiter cannot be detected it will default to comma. The -first row of the file must be a header row. +character. If the delimiter cannot be detected it will default to comma. +The first row of the file must be a header row. Usage (cli): diff --git a/docs/readme.md b/docs/readme.md index 3a1dc744..1c109fe1 100644 --- a/docs/readme.md +++ b/docs/readme.md @@ -5,59 +5,13 @@ JC - JSON CLI output utility * kellyjonbrazil@gmail.com This package serializes the output of many standard unix command line tools -to JSON format. +to dictionaries and lists of dictionaries. For documentation on each parser, see the -[documentation site](https://kellyjonbrazil.github.io/jc/). +[documentation site](https://kellyjonbrazil.github.io/jc/) or use +`jc.get_help('parser_module_name')` -CLI Example: - - $ dig example.com | jc --dig -p - [ - { - "id": 2951, - "opcode": "QUERY", - "status": "NOERROR", - "flags": [ - "qr", - "rd", - "ra" - ], - "query_num": 1, - "answer_num": 1, - "authority_num": 0, - "additional_num": 1, - "opt_pseudosection": { - "edns": { - "version": 0, - "flags": [], - "udp": 4096 - } - }, - "question": { - "name": "example.com.", - "class": "IN", - "type": "A" - }, - "answer": [ - { - "name": "example.com.", - "class": "IN", - "type": "A", - "ttl": 39302, - "data": "93.184.216.34" - } - ], - "query_time": 49, - "server": "2600:1700:bab0:d40::1#53(2600:1700:bab0:d40::1)", - "when": "Fri Apr 16 16:05:10 PDT 2021", - "rcvd": 56, - "when_epoch": 1618614310, - "when_epoch_utc": null - } - ] - -Module Example: +Example: >>> import subprocess >>> import jc @@ -65,7 +19,6 @@ Module Example: >>> cmd_output = subprocess.check_output(['dig', 'example.com'], text=True) >>> data = jc.parse('dig', cmd_output) - >>> >>> data [{'id': 64612, 'opcode': 'QUERY', 'status': 'NOERROR', ...}] @@ -78,11 +31,26 @@ modules directly: >>> cmd_output = subprocess.check_output(['dig', 'example.com'], text=True) >>> data = jc.parsers.dig.parse(cmd_output) - >>> >>> data [{'id': 64612, 'opcode': 'QUERY', 'status': 'NOERROR', ...}] -To get a list of all available parser module names, use -`jc.parser_mod_list()`. For a list of plugin parser module names only, -use the `jc.plugin_parser_mod_list()` function. +Available Functions: + +* Use `help(jc.lib)` for details + +parse(parser_module_name: str, data: str | iterable) + High-level API to easily access the parser. This API will find both + built-in parsers and local plugin parsers. + +get_help(parser_module_name: str) + Convenience function to display the help screen for a parser using its + module name. + +parser_mod_list() + Get a list of all available parser module names to be used in parse() + and get_help(). + +plugin_parser_mod_list() + Get a list of plugin parser module names. This list is a subset of + parser_mod_list().