diff --git a/EXAMPLES.md b/EXAMPLES.md index 2ebf448d..011eeea5 100644 --- a/EXAMPLES.md +++ b/EXAMPLES.md @@ -3793,5 +3793,36 @@ cat istio.yaml | jc --yaml -p } ] ``` +### zipinfo +```bash +zipinfo file.zip | jc --zipinfo -p # or: jc -p zipinfo file.zip +``` +```json +[ + { + "archive": "file.zip", + "size": 4116, + "size_unit": "bytes", + "number_entries": 1, + "number_files": 1, + "bytes_uncompressed": 11837, + "bytes_compressed": 3966, + "percent_compressed": 66.5, + "files": [ + { + "flags": "-rw-r--r--", + "zipversion": "2.1", + "zipunder": "unx", + "filesize": 11837, + "type": "bX", + "method": "defN", + "date": "21-Dec-08", + "time": "20:50", + "filename": "compressed_file" + } + ] + } +] +``` © 2019-2021 Kelly Brazil diff --git a/README.md b/README.md index de82c8f0..7ea924e3 100644 --- a/README.md +++ b/README.md @@ -188,6 +188,7 @@ The JSON output can be compact (default) or pretty formatted with the `-p` optio - `--who` enables the `who` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/who)) - `--xml` enables the XML file parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/xml)) - `--yaml` enables the YAML file parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/yaml)) +- `--zipinfo` enables the `zipinfo` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/zipinfo)) ### Options - `-a` about `jc`. Prints information about `jc` and the parsers (in JSON, of course!) diff --git a/docs/parsers/zipinfo.md b/docs/parsers/zipinfo.md new file mode 100644 index 00000000..434fd609 --- /dev/null +++ b/docs/parsers/zipinfo.md @@ -0,0 +1,106 @@ +[Home](https://kellyjonbrazil.github.io/jc/) + +# jc.parsers.zipinfo +jc - JSON CLI output utility `zipinfo` command output parser + +Options supported: +- none + +Note: The default listing format. + +Usage (cli): + + $ zipinfo | jc --zipinfo + + or + + $ jc zipinfo + +Usage (module): + + import jc.parsers.zipinfo + result = jc.parsers.zipinfo.parse(zipinfo_command_output) + +Schema: + [ + { + "archive": string, + "size": integer, + "size_unit": string, + "number_entries": integer, + "number_files": integer, + "bytes_uncompressed": integer, + "bytes_compressed": integer, + "percent_compressed": float, + "files": [ + { + "flags": string, + "zipversion": string, + "zipunder": string + "filesize": integer, + "type": string, + "method": string, + "date": string, + "time": string, + "filename": string + } + ] + } + ] + +Examples: + + $ zipinfo log4j-core-2.16.0.jar | jc --zipinfo -p + + [ + { + "archive": "log4j-core-2.16.0.jar", + "size": 1789565, + "size_unit": "bytes", + "number_entries": 1218, + "number_files": 1218, + "bytes_uncompressed": 3974141, + "bytes_compressed": 1515455, + "percent_compressed": 61.9, + "files": [ + { + "flags": "-rw-r--r--", + "zipversion": "2.0", + "zipunder": "unx", + "filesize": 19810, + "type": "bl", + "method": "defN", + "date": "21-Dec-12", + "time": "23:35", + "filename": "META-INF/MANIFEST.MF" + }, + ... + + +## info +```python +info() +``` +Provides parser metadata (version, author, etc.) + +## parse +```python +parse(data, raw=False, quiet=False) +``` + +Main text parsing function + +Parameters: + + data: (string) text data to parse + raw: (boolean) output preprocessed JSON if True + quiet: (boolean) suppress warning messages if True + +Returns: + + List of Dictionaries. Raw or processed structured data. + +## Parser Information +Compatibility: linux, darwin + +Version 0.01 by Matt J (https://github.com/listuser) diff --git a/man/jc.1 b/man/jc.1 index f953c5a6..b0e12db6 100644 --- a/man/jc.1 +++ b/man/jc.1 @@ -1,4 +1,4 @@ -.TH jc 1 2021-12-08 1.17.4 "JSON CLI output utility" +.TH jc 1 2021-12-21 1.17.4 "JSON CLI output utility" .SH NAME jc \- JSONifies the output of many CLI tools and file-types .SH SYNOPSIS @@ -427,6 +427,11 @@ XML file parser \fB--yaml\fP YAML file parser +.TP +.B +\fB--zipinfo\fP +`zipinfo` command parser + .RE .PP