News for hackers. Stuff that matters.
Re:GitHub – nushell/nushell: A new type of shell by vips7L on Wednesday June 16, 2021 @09:13AM (#27528133)
In powershell you would use built ins.

To download json over rest you would use Invoke-RestMethod or irm.

To convert json to objects you would use ConvertFrom-Json.

To select properties from objects you would use Select-Object or select.

Here is a concrete example that I wrote for the rustlings install script: https://github.com/rust-lang/rustlings/blob/main/install.ps1...

Note that I used Invoke-WebRequest instead of irm here.

Re:GitHub – nushell/nushell: A new type of shell by d0mine on Saturday June 19, 2021 @04:52AM (#27558964)
It looks like: `curl <url> | jq .tag_name` Note: curl & jq are independent programs (as long as `curl` produce json text with tag_name in each, the command works, no matter other changes).

If ConvertFrom-Json & Select-Object were not builtin, how much information about each other would they need to cooperate? Can an unrelated change in ConvertFrom-Json's output break corresponding Select-Object command? How much are they intertangled?

Re:GitHub – nushell/nushell: A new type of shell by vips7L on Sunday June 20, 2021 @10:06PM (#27575594)
Curl to python is actually what happens in the Linux install script [0].

To your point, all cmdlets adhere to an interface so they always return and receive typed data. They don’t really need to know anything except that they’re receiving or giving powershell objects.

Non built in commands (native binaries) just pipe a stream of bytes just like any posix shell.

Re:GitHub – nushell/nushell: A new type of shell by bobalob_wtf on Saturday June 19, 2021 @09:49AM (#27560439)
ConvertFrom-Json converts json text into a PowerShell object with properties derived from the json.

Select-Object (in this instance) selects a property from the object.

An unrelated change in ConvertFrom-Json wouldn't change it's basic nature which is to convert json into something you can manipulate with other PowerShell cmdlets.

Re:GitHub – nushell/nushell: A new type of shell by j1elo on Wednesday June 16, 2021 @10:54AM (#27529184)
And then I guess the shell itself has mechanisms to easily attach or register new commandlets, to allow for easily add custom object processing?

I really like the consistency that those commands have: ConvertFrom-<ConverterFormat>.

No built in converter for the format you need? I'm just speculating here, but I guess you just need to implement this or that Interface and there you go.

Re:GitHub – nushell/nushell: A new type of shell by vips7L on Wednesday June 16, 2021 @11:55AM (#27529964)
Yes you can write your own cmdlets in either C# or powershell that you can install via modules [0]

You can also just write a function in your profile.

[0] https://docs.microsoft.com/en-us/powershell/scripting/develo...

Re:GitHub – nushell/nushell: A new type of shell by godtoldmetodoit on Wednesday June 16, 2021 @11:43AM (#27529821)
You can define your own function and use it in your pipeline yes. You can have your function take pipeline input just like the built in cmdlets.