nushell.github.io icon indicating copy to clipboard operation
nushell.github.io copied to clipboard

env command doesn't output table data

Open EmilyGraceSeville7cf opened this issue 1 year ago • 1 comments

nu: 0.79.0

image

I've found no env builtin command documented on site, while it's told that this command is new:

or for a more detailed view, use our new env command.

EmilyGraceSeville7cf avatar May 14 '23 14:05 EmilyGraceSeville7cf

env used to be a built in but it isn't any longer. The docs need to be updated. These days I use this

# get the environment details
def "env details" [] {
  let e = ($env | reject config | transpose key value)
  $e | each { |r|
    let is_envc = ($r.key == ENV_CONVERSIONS)
    let is_closure = ($r.value | describe | str contains 'closure')
    let is_list = ($r.value | describe | str contains 'list')
    if $is_envc {
      echo [[key value]; 
        [($r.key) ($r.value | transpose key value | each { |ec| 
          let to_string = ($ec.value | get to_string | view source $in | nu-highlight)
          let from_string = ($ec.value | get from_string | view source $in | nu-highlight)
          echo ({'ENV_CONVERSIONS': {($ec.key): { 'to_string': ($to_string) 'from_string': ($from_string)}}})
        })]
      ]
    } else if $is_closure {
      let closure_value = (view source ($env | get $r.key) | nu-highlight)
      echo [[key value]; [($r.key) ($closure_value)]]
    } else if $is_list {
      let list_value = ($env | get $r.key | split row (char esep))
      echo [[key value]; [($r.key) ($list_value)]]
    } else {
      echo [[key value]; [($r.key) ($r.value)]]
    }
  }
}

def env [] { env details | flatten | table -e }

fdncred avatar May 14 '23 16:05 fdncred

The doc was updated at some point to reference the now-correct $env - I think this can be closed?

NotTheDr01ds avatar Aug 07 '24 12:08 NotTheDr01ds

Thanks for going through that backlog and caring for the documentation @NotTheDr01ds !

sholderbach avatar Aug 07 '24 13:08 sholderbach

Most certainly! Trying to get the queue whittled down a bit as I can ;-)

NotTheDr01ds avatar Aug 07 '24 13:08 NotTheDr01ds