Closed mailsanchu closed 2 years ago
Hi there!
Have you tried the -n
option, which disables truncation and wrapping?
You can use it in conjunction with the -S
option in less
to view long rows without wrapping.
$ cat data.json | jtbl -n | less -S
Hope that helps!
Please see the attached screenshot and you will understand what I mean
How would multiple rows work in this case? Would there be a blank line and then the next row of data would be printed - one row per column? This doesn't seem much different than pretty-printing the JSON itself.
Yes it pretty printing json in a tabular format without the curly brackets
Interesting. I could do something like add an -r
option that will "rotate" the data and print multiple single-line key-value pair tables. Thanks for the suggestion!
I think that will do it.. Thanks
I have a working prototype. Does something like this work?
$ jc -a | jq .parsers | jtbl -r
item: 0
key value
-------------- ------------------------
name acpi
argument --acpi
version 1.3
description `acpi` command parser
author Kelly Brazil
author_email kellyjonbrazil@gmail.com
compatible ['linux']
magic_commands ['acpi']
item: 1
key value
-------------- ---------------------------
name airport
argument --airport
version 1.4
description `airport -I` command parser
author Kelly Brazil
author_email kellyjonbrazil@gmail.com
compatible ['darwin']
magic_commands ['airport -I']
item: 2
key value
-------------- ---------------------------
name airport_s
argument --airport-s
version 1.5
description `airport -s` command parser
author Kelly Brazil
author_email kellyjonbrazil@gmail.com
compatible ['darwin']
magic_commands ['airport -s']
item: 3
key value
-------------- -------------------------------------
name arp
argument --arp
version 1.8
description `arp` command parser
author Kelly Brazil
author_email kellyjonbrazil@gmail.com
compatible ['linux', 'aix', 'freebsd', 'darwin']
magic_commands ['arp']
<SNIP>
item: 24
key value
------------ -----------------------------------------------
name hash
argument --hash
version 1.3
description `hash` command parser
author Kelly Brazil
author_email kellyjonbrazil@gmail.com
compatible ['linux', 'darwin', 'cygwin', 'aix', 'freebsd']
item: 25
+----------------+------------------------------------------------------------+
| key | value |
+================+============================================================+
| name | hashsum |
+----------------+------------------------------------------------------------+
| argument | --hashsum |
+----------------+------------------------------------------------------------+
| version | 1.2 |
+----------------+------------------------------------------------------------+
| description | hashsum command parser (`md5sum`, `shasum`, etc.) |
+----------------+------------------------------------------------------------+
| author | Kelly Brazil |
+----------------+------------------------------------------------------------+
| author_email | kellyjonbrazil@gmail.com |
+----------------+------------------------------------------------------------+
| details | Parses MD5 and SHA hash program output |
+----------------+------------------------------------------------------------+
| compatible | ['linux', 'darwin', 'cygwin', 'aix', 'freebsd'] |
+----------------+------------------------------------------------------------+
| magic_commands | ['md5sum', 'md5', 'shasum', 'sha1sum', 'sha224sum', 'sha25 |
| | 6sum', 'sha384sum', 'sha512sum'] |
+----------------+------------------------------------------------------------+
It respects all the same wrapping/truncating/columns arguments as well.
It looks good to me
I have published jtbl version 1.2.0 that includes this feature. Enjoy!
Tested and it works. I prefer without borders but that is ok
I agree - I was able to remove the borders for the rotate view in v1.2.1. It's now up on PyPi. Thanks!
You are a super listener. I will check and update here
I tested this and works perfectly. One small suggestion is If there is only one item, hide the item: 0 header.
Yeah, that makes sense - I can fix that today. Thanks!
Do you like the item header the way it is or would you like it to stand out more? say something like:
$ jc -a | jello _.parsers[5:7] | jtbl -r
--- Item: 0 ---
name cksum
argument --cksum
version 1.3
description `cksum` and `sum` command parser
author Kelly Brazil
author_email kellyjonbrazil@gmail.com
compatible ['linux', 'darwin', 'cygwin', 'aix', 'freebsd']
magic_commands ['cksum', 'sum']
--- Item: 1 ---
name crontab
argument --crontab
version 1.6
description `crontab` command and file parser
author Kelly Brazil
author_email kellyjonbrazil@gmail.com
compatible ['linux', 'darwin', 'aix', 'freebsd']
magic_commands ['crontab']
Item:5 -------------------------------------------------------------------------- FULL SCREEN $COLUMNS in bash key value I think some think like the above
Like this? (dashes go the entire column length)
$ jc -a | jello _.parsers[5:7] | jtbl -r
item: 0
------------------------------------------------------------------------------------------------------------
name cksum
argument --cksum
version 1.3
description `cksum` and `sum` command parser
author Kelly Brazil
author_email kellyjonbrazil@gmail.com
compatible ['linux', 'darwin', 'cygwin', 'aix', 'freebsd']
magic_commands ['cksum', 'sum']
item: 1
------------------------------------------------------------------------------------------------------------
name crontab
argument --crontab
version 1.6
description `crontab` command and file parser
author Kelly Brazil
author_email kellyjonbrazil@gmail.com
compatible ['linux', 'darwin', 'aix', 'freebsd']
magic_commands ['crontab']
Yes . What do you think?
Yeah, I think it looks good. Cool, thanks for your suggestions!
This is up on v1.2.3 now. Enjoy!
Thanks and a happy Christmas. I will not disturb you for a month as I am on holidays :)
Merry Xmas!
This will help large tables without truncating