XcodesOrg / xcodes

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

Feature request: print selected version #273

Open amosolgo-lutron opened 1 year ago

amosolgo-lutron commented 1 year ago

It's possible to parse the currently selected version number with something like: xcodes installed | grep "Selected" | awk '{print $1}'

But this relies on parsing output that is intended for human readers, which is usually not reliable or recommended practice.

Can we add an option to print the selected version? Perhaps it could be similar to xcodes select --print-path, but using --print-version / -v instead.

amosolgo-lutron commented 1 year ago

It looks like the currently selected version is already easily accessible in selectXcode: https://github.com/RobotsAndPencils/xcodes/blob/17f8c9580501138cccdf0405c7a430d63df660e5/Sources/XcodesKit/XcodeSelect.swift#L29

Perhaps that assignment could be made easrlier in the function and another block like if shouldPrint { could be added with shouldPrintVersion to print the version instead.

I don't have time to open a PR now, but I wanted to share what I found in case anyone else is interested in implementing this!