-
-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Swift-argument-parser support #369
Comments
@Kyle-Ye sorry for not getting around to it. The long term goal is to move both the toolbox and Vapor itself over to using Swift Argument Parser. However I believe when we tried it there were missing features like colour support in the terminal that would block us (and make us unable to do it in a non-breaking way) |
Maybe we could add a feature request to Swift Argument Parser to support colorful output? Or just implement the feature ourselves in a fork and hopefully it will be merged into the main branch of SAP. |
It's such a common feature to support colorful output. I maintain a CLI tool in my company and also use Swift Argument Parser as a start point. To support colorful output I just manually add something below import Foundation
/// USAGE:
/// "\("only this string will be green!", color: .green)"
public enum ASCIIColor: String, CaseIterable {
case black = "\u{001B}[0;30m"
case red = "\u{001B}[0;31m"
case green = "\u{001B}[0;32m"
case yellow = "\u{001B}[0;33m"
case blue = "\u{001B}[0;34m"
case magenta = "\u{001B}[0;35m"
case cyan = "\u{001B}[0;36m"
case white = "\u{001B}[0;37m"
case `default` = "\u{001B}[0;0m"
}
extension DefaultStringInterpolation {
mutating func appendInterpolation<T: CustomStringConvertible>(_ value: T, color: ASCIIColor) {
appendInterpolation("\(color.rawValue)\(value)\(ASCIIColor.default.rawValue)")
}
}
public func echo(with string: String, color: ASCIIColor = .default) {
print("\(string, color: color)")
} But it seems hard to do it if we want the parsed-command output to be colorful like what currently we are |
It's definitely something they should support longer term I think |
Can we use swift-argument-parser to replace vapor'console-kit. All the commands and help text will remain the same. But the code is more clear and more maintainable (in my opinion) since more people are familiar with swift-argument-parser than console-kit.
If the maintainer agree on this, I can try to make a PR for it.
The text was updated successfully, but these errors were encountered: