by agent86 · 4y ago · 0 comments
Powershell has been a gift in getting things accomplished in Windows. But one thing I've also come to enjoy using it for is quick and dirty interactions and scripting with REST APIs.
Things like Invoke-WebRequest, ConvertTo-Json/ConvertFrom-Json, Export-CSV, piping between almost everything, and the results being passed around like an object that I can use SQL-ish Select queries against, etc.
I find myself feeling like I'm missing something helpful when I'm on a Mac/Linux device. Is there a similar go to in the Mac/Linux world for this type of stuff? My current thinking is that I either have to start picking up Python or building a mental map of wget/awk/grep type commands that can be chained together for a similar effect, but I thought it best to try to learn from the wisdom of others first :-)
More from the fringe, I'm quite enjoying zx, a really nodejs powered scripting environment. https://github.com/google/zx
Covered somewhat in ZX 3.0 https://news.ycombinator.com/item?id=28195580 (189 points, 8 months ago, 163 points)
Technically true in some sense, but not really.
Personally I feel like thenbiggest missing piece ZX would beed to be a good straight up competitor to bash or zsh would be better interactive modes. A node repl.os ok, uses libreadline & has lots.of capabilities, but zx feels biased towards scripting, not am actual shell.
I dont see why you think zx couldnt be a substitute. Particularly & especially in the context of a discussion on powershell, where we are clearly already opening the gates of heterodoxy already.
Anything else tends to be either a random bag of unrelated tools sticky-taped together, OR a heavyweight programming language.
The equivalent of JavaScript or Python is C#, CS-Script, or F# Interactive. Those are also full-featured programming languages.
I can process files in just a couple of lines of C#, but I still reach for PowerShell when doing this kind of thing unless I really need higher throughputs or complex processing.
It's good to know powershell is cross platform now. Good to know this can be an option. But I'd also say the original question still deserves more exploration & thought, that asking what the romans do in rome is good to know too.
That aside, a lot of contemporary cloudy CLIs will now speak json on stdin/out and JQ will make any json transformations you can imagine.