zhiburt / tabled

An easy to use library for pretty print tables of Rust structs and enums.
MIT License
1.94k stars 77 forks source link

fancy features in nushell? #198

Open fdncred opened 2 years ago

fdncred commented 2 years ago

now that nushell is published with tabled. i'm wondering if there's a way we can demo/show off the fancy features of tabled inside of nushell? just to be clear, these are the things i'd like to see hooked up in nushell somehow exposed so that we can easily call them.

border_text

 Numbers ─┬────┬────┬────┐
│ 0  │ 1  │ 2  │ 3  │ 4  │
 More numbers ─┼────┼────┤
│ 5  │ 6  │ 7  │ 8  │ 9  │
│ 10 │ 11 │ 12 │ 13 │ 14 │
 end. ────┴────┴────┴────┘

expanded_display

-[ RECORD 0 ]------
name      | Manjaro
based_on  | Arch
is_active | true
is_cool   | true
-[ RECORD 1 ]------
name      | Arch
based_on  | 
is_active | true
is_cool   | true
-[ RECORD 2 ]------
name      | Debian
based_on  | 
is_active | true
is_cool   | true

nested_table_2

┌───────┬─────────────────────────────────────────────────┬──────────────────────────────────────────────┐
│ name  │ main_os                                         │ switch_os                                    │
├───────┼─────────────────────────────────────────────────┼──────────────────────────────────────────────┤
│ Azure │ ╔═════════╦═════════════╦═══════════╦═════════╗ │ ╔═════════╦══════════╦═══════════╦═════════╗ │
│       │ ║ name    ║ based_on    ║ is_active ║ is_cool ║ │ ║ name    ║ based_on ║ is_active ║ is_cool ║ │
│       │ ╠═════════╬═════════════╬═══════════╬═════════╣ │ ╠═════════╬══════════╬═══════════╬═════════╣ │
│       │ ║ Windows ║ Independent ║ true      ║ true    ║ │ ║ Manjaro ║ Arch     ║ true      ║ true    ║ │
│       │ ╚═════════╩═════════════╩═══════════╩═════════╝ │ ╚═════════╩══════════╩═══════════╩═════════╝ │
├───────┼─────────────────────────────────────────────────┼──────────────────────────────────────────────┤
│ AWS   │ ╔════════╦═════════════╦═══════════╦═════════╗  │ ╔══════╦═════════════╦═══════════╦═════════╗ │
│       │ ║ name   ║ based_on    ║ is_active ║ is_cool ║  │ ║ name ║ based_on    ║ is_active ║ is_cool ║ │
│       │ ╠════════╬═════════════╬═══════════╬═════════╣  │ ╠══════╬═════════════╬═══════════╬═════════╣ │
│       │ ║ Debian ║ Independent ║ true      ║ true    ║  │ ║ Arch ║ Independent ║ true      ║ true    ║ │
│       │ ╚════════╩═════════════╩═══════════╩═════════╝  │ ╚══════╩═════════════╩═══════════╩═════════╝ │
├───────┼─────────────────────────────────────────────────┼──────────────────────────────────────────────┤
│ GCP   │ ╔════════╦═════════════╦═══════════╦═════════╗  │ ╔══════╦═════════════╦═══════════╦═════════╗ │
│       │ ║ name   ║ based_on    ║ is_active ║ is_cool ║  │ ║ name ║ based_on    ║ is_active ║ is_cool ║ │
│       │ ╠════════╬═════════════╬═══════════╬═════════╣  │ ╠══════╬═════════════╬═══════════╬═════════╣ │
│       │ ║ Debian ║ Independent ║ true      ║ true    ║  │ ║ Arch ║ Independent ║ true      ║ true    ║ │
│       │ ╚════════╩═════════════╩═══════════╩═════════╝  │ ╚══════╩═════════════╩═══════════╩═════════╝ │
└───────┴─────────────────────────────────────────────────┴──────────────────────────────────────────────┘

span

┌───────────────────────────────────────────────────────────────────────────────┐
│                              span all 5 columns                               │
├───────────────────────────────────────────────────────────────┬───────────────┤
│                        span 4 columns                         │ just 1 column │
├───────────────────────────────────────────────┬───────────────┴───────────────┤
│                span 3 columns                 │        span 2 columns         │
├───────────────────────────────┬───────────────┴───────────────────────────────┤
│        span 2 columns         │                span 3 columns                 │
├───────────────┬───────────────┴───────────────────────────────────────────────┤
│ just 1 column │                        span 4 columns                         │
├───────────────┼───────────────┬───────────────┬───────────────┬───────────────┤
│ just 1 column │ just 1 column │ just 1 column │ just 1 column │ just 1 column │
└───────────────┴───────────────┴───────────────┴───────────────┴───────────────┘
zhiburt commented 2 years ago

Hi @fdncred

border_text and span could be set as an argument in table binary. Like this.

table --split-text='$row:Hello World' --span='$row,$col:$span'

Usage of expanded_display could be a flag in configuration.

According to nested_table_2 I am not sure how you can expose/use it. Because it's generally what wrap | table combination does?

What do you think?

zhiburt commented 2 years ago

There's one more thing which we could be added. We could potentially add gradient support for border color.

Here on the picture I've done it for the whole table. But I believe it could be done only for borders.

image

zhiburt commented 2 years ago

BTW: I guess you could make a different command for colorization? (maybe it's already exists)

fdncred commented 2 years ago

I'm up for testing all of these out. Here are some thoughts.

zhiburt commented 2 years ago

expanded_display - This look and feel kind of reminds me of a debug display. I wonder if we can make it useful in the debug command?

I don't know about debug. It would look something like it.

image

nested - it would be nice to have a config point that says how many levels we should try to expand automatically. so when tables are drawn, they are initially drawn with embedded tables down to a certain level. This kind of sounds complicated to me though.

But what you do when the level is reached. Just ignore the content?

I'd also like to be able to do some of this stuff with literals somehow, so we'd need to come up with a syntax. For instance, a table now is [[col1 col2]; [1 2] [3 4]]. It would be cool to augment that syntax to support spans first and maybe other things later.

:+1:

span, border_text - Generally I like the idea of having flags/params on the table command to tweak the output. I think this would be a good start. I'm wondering if there are other commands that can benefit from border_text or spans now just based on the data they return? For instance, I wonder if it's helpful on keybindings default to have a span header row for each section for emacs,vi_normal,vi_insert? I'm just not sure what the code would look like in nushell to do this fancy stuff.

It may be suitable for some cases I guees. But it will require to pass a configuration information by Pipeline I guess.

image

fdncred commented 2 years ago

I don't really think the debug example above looks very nice. I'm just trying to think of a way to use that output. I'm open to ideas.

I do think keybindings one looks pretty cool.

Really, the idea is just to expose your awesome table formatting so we can use it somehow to make nushell tables look better.

fdncred commented 2 years ago

@zhiburt Are you on discord? We've launched a new #clubhouse for people who have at least 20 PRs and you qualify! If you don't participate on Discord, that's cool. I just wanted to include you if possible. :)

zhiburt commented 2 years ago

@zhiburt Are you on discord? We've launched a new #clubhouse for people who have at least 20 PRs and you qualify! If you don't participate on Discord, that's cool. I just wanted to include you if possible. :)

Appreciate it, But It was probably not deserved :smiling_face_with_tear:. As I can imagine most of my PRs were fixes of regression/issue. So I think I was placed in the list by mistake. But I took a note thanks.

zhiburt commented 2 years ago

I had an idea to build a table for serde_json::Value for a while, and today got to this. It looks not ideal I'd say. But I can't yet came up how to make it better.

json

{
        "glossary": {
            "title": "example glossary",
            "GlossDiv": {
                "title": "S",
                "GlossList": {
                    "GlossEntry": {
                        "ID": "SGML",
                        "SortAs": "SGML",
                        "GlossTerm": "Standard Generalized Markup Language",
                        "Acronym": "SGML",
                        "Abbrev": "ISO 8879:1986",
                        "GlossDef": {
                            "para": "A meta-markup language, used to create markup languages such as DocBook.",
                            "GlossSeeAlso": ["GML", "XML"]
                        },
                        "GlossSee": "markup"
                    }
                }
            }
        }
    }

version 1

┌──────────┬─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ glossary │ ┌──────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │
│          │ │ GlossDiv │ ┌───────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │ │
│          │ │          │ │ GlossList │ ┌────────────┬─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │ │ │
│          │ │          │ │           │ │ GlossEntry │ ┌───────────┬─────────────────────────────────────────────────────────────────────────────────────────────────┐ │ │ │ │
│          │ │          │ │           │ │            │ │ Abbrev    │ ┌───────────────┐                                                                               │ │ │ │ │
│          │ │          │ │           │ │            │ │           │ │ ISO 8879:1986 │                                                                               │ │ │ │ │
│          │ │          │ │           │ │            │ │           │ └───────────────┘                                                                               │ │ │ │ │
│          │ │          │ │           │ │            │ ├───────────┼─────────────────────────────────────────────────────────────────────────────────────────────────┤ │ │ │ │
│          │ │          │ │           │ │            │ │ Acronym   │ ┌──────┐                                                                                        │ │ │ │ │
│          │ │          │ │           │ │            │ │           │ │ SGML │                                                                                        │ │ │ │ │
│          │ │          │ │           │ │            │ │           │ └──────┘                                                                                        │ │ │ │ │
│          │ │          │ │           │ │            │ ├───────────┼─────────────────────────────────────────────────────────────────────────────────────────────────┤ │ │ │ │
│          │ │          │ │           │ │            │ │ GlossDef  │ ┌──────────────┬──────────────────────────────────────────────────────────────────────────────┐ │ │ │ │ │
│          │ │          │ │           │ │            │ │           │ │ GlossSeeAlso │ ┌─────────┐                                                                  │ │ │ │ │ │
│          │ │          │ │           │ │            │ │           │ │              │ │ ┌─────┐ │                                                                  │ │ │ │ │ │
│          │ │          │ │           │ │            │ │           │ │              │ │ │ GML │ │                                                                  │ │ │ │ │ │
│          │ │          │ │           │ │            │ │           │ │              │ │ └─────┘ │                                                                  │ │ │ │ │ │
│          │ │          │ │           │ │            │ │           │ │              │ ├─────────┤                                                                  │ │ │ │ │ │
│          │ │          │ │           │ │            │ │           │ │              │ │ ┌─────┐ │                                                                  │ │ │ │ │ │
│          │ │          │ │           │ │            │ │           │ │              │ │ │ XML │ │                                                                  │ │ │ │ │ │
│          │ │          │ │           │ │            │ │           │ │              │ │ └─────┘ │                                                                  │ │ │ │ │ │
│          │ │          │ │           │ │            │ │           │ │              │ └─────────┘                                                                  │ │ │ │ │ │
│          │ │          │ │           │ │            │ │           │ ├──────────────┼──────────────────────────────────────────────────────────────────────────────┤ │ │ │ │ │
│          │ │          │ │           │ │            │ │           │ │ para         │ ┌──────────────────────────────────────────────────────────────────────────┐ │ │ │ │ │ │
│          │ │          │ │           │ │            │ │           │ │              │ │ A meta-markup language, used to create markup languages such as DocBook. │ │ │ │ │ │ │
│          │ │          │ │           │ │            │ │           │ │              │ └──────────────────────────────────────────────────────────────────────────┘ │ │ │ │ │ │
│          │ │          │ │           │ │            │ │           │ └──────────────┴──────────────────────────────────────────────────────────────────────────────┘ │ │ │ │ │
│          │ │          │ │           │ │            │ ├───────────┼─────────────────────────────────────────────────────────────────────────────────────────────────┤ │ │ │ │
│          │ │          │ │           │ │            │ │ GlossSee  │ ┌────────┐                                                                                      │ │ │ │ │
│          │ │          │ │           │ │            │ │           │ │ markup │                                                                                      │ │ │ │ │
│          │ │          │ │           │ │            │ │           │ └────────┘                                                                                      │ │ │ │ │
│          │ │          │ │           │ │            │ ├───────────┼─────────────────────────────────────────────────────────────────────────────────────────────────┤ │ │ │ │
│          │ │          │ │           │ │            │ │ GlossTerm │ ┌──────────────────────────────────────┐                                                        │ │ │ │ │
│          │ │          │ │           │ │            │ │           │ │ Standard Generalized Markup Language │                                                        │ │ │ │ │
│          │ │          │ │           │ │            │ │           │ └──────────────────────────────────────┘                                                        │ │ │ │ │
│          │ │          │ │           │ │            │ ├───────────┼─────────────────────────────────────────────────────────────────────────────────────────────────┤ │ │ │ │
│          │ │          │ │           │ │            │ │ ID        │ ┌──────┐                                                                                        │ │ │ │ │
│          │ │          │ │           │ │            │ │           │ │ SGML │                                                                                        │ │ │ │ │
│          │ │          │ │           │ │            │ │           │ └──────┘                                                                                        │ │ │ │ │
│          │ │          │ │           │ │            │ ├───────────┼─────────────────────────────────────────────────────────────────────────────────────────────────┤ │ │ │ │
│          │ │          │ │           │ │            │ │ SortAs    │ ┌──────┐                                                                                        │ │ │ │ │
│          │ │          │ │           │ │            │ │           │ │ SGML │                                                                                        │ │ │ │ │
│          │ │          │ │           │ │            │ │           │ └──────┘                                                                                        │ │ │ │ │
│          │ │          │ │           │ │            │ └───────────┴─────────────────────────────────────────────────────────────────────────────────────────────────┘ │ │ │ │
│          │ │          │ │           │ └────────────┴─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ │ │ │
│          │ │          │ ├───────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤ │ │
│          │ │          │ │ title     │ ┌───┐                                                                                                                            │ │ │
│          │ │          │ │           │ │ S │                                                                                                                            │ │ │
│          │ │          │ │           │ └───┘                                                                                                                            │ │ │
│          │ │          │ └───────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ │ │
│          │ ├──────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤ │
│          │ │ title    │ ┌──────────────────┐                                                                                                                             │ │
│          │ │          │ │ example glossary │                                                                                                                             │ │
│          │ │          │ └──────────────────┘                                                                                                                             │ │
│          │ └──────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ │
└──────────┴─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

version 2

┌──────────┬─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ glossary │  GlossDiv │  GlossList │  GlossEntry │  GlossDef  │  GlossSeeAlso │   GML                                                                           │
│          │           │            │             │            │               │ ───────                                                                         │
│          │           │            │             │            │               │   XML                                                                           │
│          │           │            │             │            │ ──────────────┼────────────────────────────────────────────────────────────────────────────     │
│          │           │            │             │            │  para         │  A meta-markup language, used to create markup languages such as DocBook.       │
│          │           │            │             │ ───────────┼─────────────────────────────────────────────────────────────────────────────────────────────    │
│          │           │            │             │  SortAs    │  SGML                                                                                           │
│          │           │            │             │ ───────────┼─────────────────────────────────────────────────────────────────────────────────────────────    │
│          │           │            │             │  GlossSee  │  markup                                                                                         │
│          │           │            │             │ ───────────┼─────────────────────────────────────────────────────────────────────────────────────────────    │
│          │           │            │             │  GlossTerm │  Standard Generalized Markup Language                                                           │
│          │           │            │             │ ───────────┼─────────────────────────────────────────────────────────────────────────────────────────────    │
│          │           │            │             │  ID        │  SGML                                                                                           │
│          │           │            │             │ ───────────┼─────────────────────────────────────────────────────────────────────────────────────────────    │
│          │           │            │             │  Abbrev    │  ISO 8879:1986                                                                                  │
│          │           │            │             │ ───────────┼─────────────────────────────────────────────────────────────────────────────────────────────    │
│          │           │            │             │  Acronym   │  SGML                                                                                           │
│          │           │ ───────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────  │
│          │           │  title     │  S                                                                                                                         │
│          │ ──────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── │
│          │  title    │  example glossary                                                                                                                       │
└──────────┴─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

style 1

┌──────────┬─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ glossary │  GlossDiv |  GlossList |  GlossEntry |  GlossSee  |  markup                                                                                         │
│          │           |            |             |  ID        |  SGML                                                                                           │
│          │           |            |             |  GlossTerm |  Standard Generalized Markup Language                                                           │
│          │           |            |             |  Acronym   |  SGML                                                                                           │
│          │           |            |             |  SortAs    |  SGML                                                                                           │
│          │           |            |             |  GlossDef  |  GlossSeeAlso |   GML                                                                           │
│          │           |            |             |            |               |   XML                                                                           │
│          │           |            |             |            |  para         |  A meta-markup language, used to create markup languages such as DocBook.       │
│          │           |            |             |  Abbrev    |  ISO 8879:1986                                                                                  │
│          │           |  title     |  S                                                                                                                         │
│          │  title    |  example glossary                                                                                                                       │
└──────────┴─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

style 2

┌──────────┬────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ glossary │  GlossDiv   title       S                                                                                                                      │
│          │            ----------------------------------------------------------------------------------------------------------------------------------  │
│          │             GlossList   GlossEntry   Abbrev      ISO 8879:1986                                                                                 │
│          │                                     -------------------------------------------------------------------------------------------------------    │
│          │                                      Acronym     SGML                                                                                          │
│          │                                     -------------------------------------------------------------------------------------------------------    │
│          │                                      ID          SGML                                                                                          │
│          │                                     -------------------------------------------------------------------------------------------------------    │
│          │                                      GlossTerm   Standard Generalized Markup Language                                                          │
│          │                                     -------------------------------------------------------------------------------------------------------    │
│          │                                      GlossSee    markup                                                                                        │
│          │                                     -------------------------------------------------------------------------------------------------------    │
│          │                                      SortAs      SGML                                                                                          │
│          │                                     -------------------------------------------------------------------------------------------------------    │
│          │                                      GlossDef    GlossSeeAlso    GML                                                                           │
│          │                                                                -------                                                                         │
│          │                                                                  XML                                                                           │
│          │                                                 ------------------------------------------------------------------------------------------     │
│          │                                                  para           A meta-markup language, used to create markup languages such as DocBook.       │
│          │ ---------------------------------------------------------------------------------------------------------------------------------------------- │
│          │  title      example glossary                                                                                                                   │
└──────────┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

style 3

 glossary   GlossDiv   GlossList   GlossEntry   Abbrev      ISO 8879:1986                                                                                 
                                                GlossTerm   Standard Generalized Markup Language                                                          
                                                GlossDef    GlossSeeAlso    GML                                                                           
                                                                            XML                                                                           
                                                            para           A meta-markup language, used to create markup languages such as DocBook.       
                                                GlossSee    markup                                                                                        
                                                ID          SGML                                                                                          
                                                Acronym     SGML                                                                                          
                                                SortAs      SGML                                                                                          
                       title       S                                                                                                                      
            title      example glossary                                                                                                                   

Why I am writing is that I think we could convert nu_protocol::Value into table as well. The only difference from json is that you have terminal width constrain. So the output would be simillar to what nushell/nana shows.

image

The version 2 is suppose to mimic its style but as you see there's issue with not complete borders. Not sure how to fix it to be honest.

What do you @fdncred think about it?

fdncred commented 2 years ago

@zhiburt I like it. I was thinking about this the other day too and was hoping for a nushell table literal syntax but I'm good with a json syntax too.

Nushell table syntax currently is like this: [[column1 column2]; [1 2] [3 4] [5 6]]

I'm fine with starting fancier table drawing with json.

zhiburt commented 1 year ago

Sorry for the delay.

It took me more effort than I was thinking.... (I can imagine there are some issues there still..... :disappointed:)

You can see some examples of json conversion here. https://github.com/zhiburt/tabled/blob/25ee089cdea14dae6c6703245b61a36314755f5a/json_to_table/tests/test_table.rs

@zhiburt I like it. I was thinking about this the other day too and was hoping for a nushell table literal syntax but I'm good with a json syntax too.

So you mean to build a table with a custom layout from CLI? Interesting idea. Could you elaborate a bit more?

I initially meant a bit different thing actually. We could make all tables like that by converting nu_protocol::Value.

But I assure you now, it's a bad idea (to do it as a default at least). Cause from what I've seen it will a BIG hit on performance.

ref: #226 cc @fdncred

fdncred commented 1 year ago

You can see some examples of json conversion here.

These are super cool.

What I don't understand though is how we can make that work in nushell. If we have nushell consume a json string, it'll just make it into a typical json table and not a fancy one. Like this: image

So, the only way I can think about making fancy tables work in nushell is either by table literal or a new table subcommand.

table literal syntax is currently limited to this

So, if we were going to make fancy tables with nushell literals, we'd have to have some special syntax to indicate the new things like spans, or visible tables in tables vs collapsed tables like we do today.

Alternatively, if we have a new table subcommand like table fancy (or some other name) we can make it understand your json syntax and instead of just rendering the typicaly nushell json table, we make it render like tabled does in your examples.

zhiburt commented 1 year ago

Alternatively, if we have a new table subcommand like table fancy (or some other name) we can make it understand your json syntax and instead of just rendering the typicaly nushell json table, we make it render like tabled does in your examples.

I am not sure if need to incorporate any syntax. I think it could be good enough to use it like.

some commands | table expand --collapse

(Not sure if we can do it this way though)

I've just converted nu_protocol::Value to serde_json::Value. And here's a partial output of sys.

image

fdncred commented 1 year ago

That looks cool

zhiburt commented 1 year ago

Just noticed one thing.

See this section,

image

like it differs from this

image

I've just checked and the reason is because sessions is actually a list of maps. Meaning to be compatible we would need to check if vector elements have the same object schema (the same columns).

fdncred commented 1 year ago

hmmmm. ya, it looks like maybe it needs flattening

sys | get host | get sessions | to json
[
  {
    "name": "Administrator",
    "groups":
    [
      "Administrators"
    ]
  },
  {
    "name": "DefaultAccount",
    "groups":
    [
      "System Managed Accounts Group"
    ]
  },
  {
    "name": "dschroeder",
    "groups":
    [
      "Administrators"
    ]
  },
  {
    "name": "Guest",
    "groups":
    [
      "Guests"
    ]
  },
  {
    "name": "WDAGUtilityAccount",
    "groups": []
  }
]

with flatten

sys | get host | get sessions | flatten
╭───┬────────────────┬───────────────────────────────╮
│ # │      name      │            groups             │
├───┼────────────────┼───────────────────────────────┤
│ 0 │ Administrator  │ Administrators                │
│ 1 │ DefaultAccount │ System Managed Accounts Group │
│ 2 │ dschroeder     │ Administrators                │
│ 3 │ Guest          │ Guests                        │
├───┼────────────────┼───────────────────────────────┤
│ # │      name      │            groups             │
╰───┴────────────────┴───────────────────────────────╯
zhiburt commented 1 year ago

Spend some time to fix it.

image

But I think we can't fully represent nushell data as a json because of the format. Specifically see like we lose the alignment of the table. It's because of the format you've showed we convert to map<map<map<.... which is the best we can do.

image

fdncred commented 1 year ago

I don't understand this really because if you do sys | to json everything lines up like this for cpu:

  "cpu":
  [
    {
      "name": "CPU 1",
      "brand": "Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz",
      "cpu_usage": 0,
      "load_average": "0.00, 0.00, 0.00",
      "vendor_id": "GenuineIntel",
      "freq": 8
    },
    {
      "name": "CPU 2",
      "brand": "Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz",
      "cpu_usage": 0,
      "load_average": "0.00, 0.00, 0.00",
      "vendor_id": "GenuineIntel",
      "freq": 8
    },
zhiburt commented 1 year ago

Right, but we probably can't use this json exactly like this.

Currently running your json we would get exactly this. It may be an incorrect representation though let me now what you think.

image

Currently it's doing a conversion to a json similar to this. So we get a table look, but because we are using arrays there's no alignment in between of the objects.

I didn't came up with good analogue schemes to do the job better than that :disappointed:

[
  { "name": { "brand": { "cpu_usage": ... } } },
  { "CPU 1": { "Inte(R) ...": { "0": ... } } },
  { "CPU 1": { "Inte(R) ...": { "0": ... } } },
]

image

fdncred commented 1 year ago

It may be an incorrect representation though let me now what you think.

I could probably live with that. It just has the columns and rows swapped but it may be ok for a first pass.

zhiburt commented 1 year ago

It just has the columns and rows swapped

I tend to believe it's because HashMap is used. And it implies a different ordering.

But I think it would be cool to be able to preserve it somehow.

zhiburt commented 1 year ago

moving header on the border;

image

use colors as borders.

image

fdncred commented 1 year ago

nice work! I personally like the header-on-border look. I'll ask the core-team to look at these.

fdncred commented 1 year ago

@zhiburt is it possible to get the header-on-border as one of the table themes like rounded, basic, etc, so people can just enable it easily via their config file?

fdncred commented 1 year ago

@zhiburt I also noticed in your screenshot that the first line of the size column and the modified column are not aligned properly.

fdncred commented 1 year ago

@zhiburt I really like the header on the border. How do we enable that as an option in nushell?