Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add my changes #727

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 75 additions & 3 deletions blog/2023-01-10-nushell_0_74.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ The current batch of improvements can still be taken further. For example, custo

## `values` command to programmatically interact with records ([webbedspace](https://github.com/nushell/nushell/pull/7583))

This is a complement to `columns`, designed to allow the values of a record to be easily filtered and iterated over using the standard list tools like `each` and `where`. The name `values` is derived from similar functions in Ruby, Python and JavaScript.

```sh
> {a: "Happy", b: "new", c: "year"} | values
╭───┬───────╮
Expand All @@ -119,15 +121,85 @@ The current batch of improvements can still be taken further. For example, custo
╰───┴───────╯
```

It can also operate on tables to convert them to lists-of-lists:

```sh
> [[a b]; [4 7] [5 8] [6 9]] | values
╭───┬───────────╮
│ 0 │ ╭───┬───╮ │
│ │ │ 0 │ 4 │ │
│ │ │ 1 │ 5 │ │
│ │ │ 2 │ 6 │ │
│ │ ╰───┴───╯ │
│ 1 │ ╭───┬───╮ │
│ │ │ 0 │ 7 │ │
│ │ │ 1 │ 8 │ │
│ │ │ 2 │ 9 │ │
│ │ ╰───┴───╯ │
╰───┴───────────╯
```

## `get`, `select`, cell path access on tables will now error when encountering a hole ([kubouch](https://github.com/nushell/nushell/pull/7002), [webbedspace](https://github.com/nushell/nushell/pull/7647))

Consider the following operations performed on a table:

- `[{foo: 'bar'}, {}] | select foo`
- `[{foo: 'bar'}, {}] | get foo`
- `[{foo: 'bar'}, {}].foo`

Formerly, this would produce `['bar', null]` - converting the table hole into a `null`. Now, however, they will produce an error. The original null-conversion behaviour can, as usual, be opted into using the `-i` flag for `get` and `select`: `[{foo: 'bar'}, {}] | get -i foo` produces `['bar', null]`. (There are also plans for a future version of Nushell to expand the cell path syntax to allow certain cell names to be "nullable" - converted to `null` if they don't exist.)

## Behavior of `-i`/`--ignore-errors` flag for `get` and `select` when the entire column is absent has changed

Formerly, if `select -i` or `get -i` couldn't find any value for the given column, it would produce a single `null`:

```sh
〉[{a:1} {b:2} {a:3}] | select -i foo | to nuon
null
```

This has been changed so that it now produces a table (or, in the case of `get`, a list) of all `null`s:

```sh
〉[{a:1} {b:2} {a:3}] | select -i foo | to nuon
[[foo]; [null], [null], [null]]
```

This change was made to make this flag work more consistently with `default` and `compact`:

```sh
〉[{a:1} {b:2} {a:3}] | select -i a | default 0 a
[[a]; [1], [0], [3]]
〉[{a:1} {b:2} {a:3}] | select -i foo | default 0 foo
[[foo]; [0], [0], [0]]
```

As you can see, `default` in the above example can reliably populate an entire table column when some or all of the values don't exist.

## Certain misused punctuation in `def` definitions are now errors ([webbedspace](https://github.com/nushell/nushell/pull/7624), [webbedspace](https://github.com/nushell/nushell/pull/7606))

The following misuses of punctuation in `def` definitions now produce errors:

- Placing a comma between a long flag and its short alternative (e.g. `def a [--foo, (-f)] {}`)
- Consecutive commas, like `def a [foo,,bar] {}`
- Consecutive colons, like `def a [foo::int] {}`
- Using `^` in command names, like `def ^a [] {}`

## `$in` now works in `catch` closures

`$in` in `catch` closures now behaves identically to how it does in other closures, like those given to `each` (it's equivalent to what would be the first named argument).

`try { 'x' | math abs } catch { print $in }` behaves the same as `try { 'x' | math abs } catch {|e| print $e }`.

## MIME-types are supported in `ls` with an additional flag. ([fdncred](https://github.com/nushell/nushell/pull/7616))

To find out what applications your operating system associates with particular files you can now use the `--mime-type` or `-m` flag on our `ls` command.
To find out what application your operating system associates with a particular file, you can now use the `--mime-type` or `-m` flag on our `ls` command.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This statement about application associations seems to indicate we display application names in ls, which we do not. We show mime-types that were guessed at by file extensions and I think that is the extent of the change.

This simplifies filtering for particular files and can help you dispatch files to particular programs.
When opening files with nushell directly `open` will still follow the same heuristics using file endings and the built-in `from ...` command parsers.
When opening files with Nushell directly, `open` will still follow the same heuristics using file endings and the built-in `from ...` command parsers.

## Regular expression queries are cached for performance ([rgwood](https://github.com/nushell/nushell/pull/7587))

Stonksmeme.png
The primary motivation for this is to make regex and `=~` operator uses in hooks and `color_config` closures more performant.

## All built-in commands now declare their pipeline input and output types ([sholderbach](https://github.com/nushell/nushell/pull/7532))

Expand Down