nushell / nushell.github.io

Nushell's main website, blog, book, and more
https://www.nushell.sh/book/
MIT License
183 stars 434 forks source link

Add missing cmd to nu command #1637

Closed Kissaki closed 1 day ago

Kissaki commented 2 days ago

Add if defined expression via scope variables

fdncred commented 1 day ago

Thanks

NotTheDr01ds commented 1 day ago

How about?

if '$<variable>' in (scope variables).name { <command> }
Kissaki commented 1 day ago

@NotTheDr01ds I see. Not having to define a closure arguably means simpler syntax.

I wasn't aware in could be used like that, with a list-collect+path-get.

I was thinking about potential performance differences as well, but it seems like (scope variables).name would or could be streaming data in the same way.

Overall, I don't think there's a clear winner. They're alternative query approaches. Makes me wonder if adding both alternatives would make sense.

fdncred commented 1 day ago

I do think this is more nushell idiomatic. This example should probably be updated.

'$rn' in (scope variables).name
Kissaki commented 1 day ago

I created #1643 for it.