Closed rymcol closed 5 years ago
Hey @rymcol. Looks like an excellent contribution! 😄
Spacefish aims to achieve feature-parity with spaceship-prompt, the original prompt that this is a port of. Spaceship-prompt appears to have a Swift section, though it appears to differ by using the version of Swift set by swiftenv
rather than the version of swift being called by swift --version
.
In order to maintain feature parity of the projects we can do one of two things:
swiftenv
)swift
in addition to swiftenv
, as we have in the Node section (supporting node
and nvm
). Once an issue or PR is approved and planned for development/release, we can go ahead and merge this in.I sincerely appreciate the work you've put into making a Swift section and would love to have it added to spacefish!
I think it is probably smarter to build it like node
/nvm
with swift
/swiftenv
because swiftenv
is a third party tool which is not bundled with swift
. I'm certain most swift
developers probably do use swiftenv
, but you certainly do not have to.
The other problem I have with that is that the output of swiftenv version
alone does not always output an actual version number, sometimes it outputs "system" or other labels:
~ at ☸️ minikube
➜ swiftenv version
system (set by /Users/ryan/.swiftenv/version)
~ at ☸️ minikube
➜ swiftenv versions
* system
3.1.1
4.0
4.1.2
5.0-DEVELOPMENT-SNAPSHOT-2019-01-23-a
4.2.1
5.0
~ at ☸️ minikube
➜ swiftenv global 5.0-DEVELOPMENT-SNAPSHOT-2019-01-23-a
~ at ☸️ minikube
➜ swiftenv version
5.0-DEVELOPMENT-SNAPSHOT-2019-01-23-a (set by /Users/ryan/.swiftenv/version)
~ at ☸️ minikube
➜ swift --version
Apple Swift version 5.0-dev (LLVM eb302e257f, Clang a113643bc4, Swift 646034c539)
Target: x86_64-apple-darwin18.5.0
~ at ☸️ minikube
➜ swiftenv global 3.1.1
~ at ☸️ minikube
➜ swift --version
Apple Swift version 3.1 (swift-3.1.1-RELEASE)
Target: x86_64-apple-macosx10.9
Further to the swiftenv
labels, they can be a bit deceiving if you've forgotten which command line tools you have selected:
~ at ☸️ minikube
➜ sudo xcode-select -s /Applications/Xcode-beta.app
~ at ☸️ minikube
➜ swiftenv version
system (set by /Users/ryan/.swiftenv/version)
~ at ☸️ minikube
➜ swift --version
Apple Swift version 5.0 (swiftlang-1001.0.45.7 clang-1001.0.37.7)
Target: x86_64-apple-darwin18.5.0
ABI version: 0.6
~ at ☸️ minikube
➜ sudo xcode-select -s /Applications/Xcode.app
~ at ☸️ minikube
➜ swiftenv version
system (set by /Users/ryan/.swiftenv/version)
~ at ☸️ minikube
➜ swift --version
Apple Swift version 4.2.1 (swiftlang-1000.11.42 clang-1000.11.45.1)
Target: x86_64-apple-darwin18.5.0
Agreed, swift
/swiftenv
would definitely be a better solution. 👍
Closing this issue until a similar feature is implemented upstream.
Adds Swift language version section
Description
Adds function to detect Swift and add Swift version to the prompt. Also adds unit tests + documentation.
Motivation and Context
I use development & production versions of Swift personally, and this is quite helpful.
Types of changes
Screenshots (if appropriate):
How Has This Been Tested?
Changes use the default API and should not cause any unexpected behavior. Unit tests and version identification code were borrowed from the current golang implementation, so they should function as expected on all current platforms. Unit tests were written and are passing as of the PR. Manually tested on:
macOS System Version: macOS 10.14.4 (18E174f) Kernel Version: Darwin 18.5.0
Checklist: