XcodesOrg / xcodes

The best command-line tool to install and switch between multiple versions of Xcode.
MIT License
3.59k stars 119 forks source link

Add the ability to stream download to stdout #298

Open saagarjha opened 1 year ago

saagarjha commented 1 year ago

People have been poking me about how to download Xcode because copying curl commands with cookies is kind of annoying. It would be nice if I could just point them at xcodes and let them pipe the output of that into whatever streaming tools want to handle the results.

MattKiazyk commented 1 year ago

Hey @saagarjha - first thanks for the tool!

I looked into updates Xcodes to handle your changes on unxip, but a few things came up. 1) aria2 doesn't support standard output, 2) neither does urlsession (The 2 options currently for network).

So we'd have to use regular curl calls - not that it couldn't be possible, just letting everybody know what the option would have to be.

saagarjha commented 1 year ago

URLSession definitely supports streaming downloads that you can hook up to standard out. The easiest way to do this, if you support Swift Concurrency, is to just use the functions returning an AsyncBytes. Otherwise you can wire up one of the delegate methods to dump the data as it arrives.

MattKiazyk commented 1 year ago

Thank you - i have something to learn about! Currently the CLI uses PromiseKit still. There is an ongoing effort to have a single framework(to rule them all) so both CLI and UI use the same code to do most of their features.