mirror of
https://github.com/apple/swift-argument-parser.git
synced 2026-05-07 20:12:41 +00:00
34300696f5
* Prefix testing and test helper targets with ArgumentParser * Replace SAP with ArgumentParser in imports and CMakeLists
29 lines
812 B
Swift
29 lines
812 B
Swift
//===----------------------------------------------------------*- swift -*-===//
|
|
//
|
|
// This source file is part of the Swift Argument Parser open source project
|
|
//
|
|
// Copyright (c) 2020 Apple Inc. and the Swift project authors
|
|
// Licensed under Apache License v2.0 with Runtime Library Exception
|
|
//
|
|
// See https://swift.org/LICENSE.txt for license information
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
extension Substring {
|
|
func trimmed() -> Substring {
|
|
guard let i = lastIndex(where: { $0 != " "}) else {
|
|
return ""
|
|
}
|
|
return self[...i]
|
|
}
|
|
}
|
|
|
|
extension String {
|
|
public func trimmingLines() -> String {
|
|
return self
|
|
.split(separator: "\n", omittingEmptySubsequences: false)
|
|
.map { $0.trimmed() }
|
|
.joined(separator: "\n")
|
|
}
|
|
}
|