Skip to content
This repository was archived by the owner on Jan 1, 2022. It is now read-only.

Commit 692d398

Browse files
committed
Remove debug print
1 parent 0e3158f commit 692d398

File tree

5 files changed

+12
-15
lines changed

5 files changed

+12
-15
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.DS_Store
22
/.build
33
/Packages
4+
/.swiftpm
45
/*.xcodeproj

Sources/CLInterface/Argument Types/Argument.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public final class Argument<T : ArgumentType> {
3535
/// - Parameter longName: Name for your option, e.g. "--output"
3636
/// - Parameter shortName: Alternative short name, e.g. "-o"
3737
/// - Parameter usage: Usage string, describing what this argument does. Shown to user in `--help` menu. If omitted, it won't be shown there
38-
/// - Parameter default: Optional default value. If provided, it is safe to unwrap this property
38+
/// - Parameter default: Optional default value
3939
public init(_ longName: String, _ shortName: String? = nil, usage: String? = nil, default: T.Base? = nil) {
4040
self.longName = longName
4141
self.shortName = shortName
@@ -50,7 +50,6 @@ public final class Argument<T : ArgumentType> {
5050
case (false, _):
5151
self.mode = .optional(default: `default`)
5252
}
53-
print("\(longName) is \(mode)")
5453
}
5554

5655
func register(with argumentParser: ArgumentParser) {

Sources/CLInterface/Argument Types/PositionalArgument.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ public final class PositionalArgument<T: BaseArgumentType> {
2626
/// - Parameter name: Shown in `--help` menu, e.g. "files"
2727
/// - Parameter usage: Usage string, describing these arguments. Shown to user in `--help` menu. If omitted, it won't be shown there
2828
/// - Parameter default: Optional default value. If omitted, default is empty array.
29-
public init(name: String, usage: String? = nil, default: [T]? = nil) {
29+
public init(name: String, usage: String? = nil, default: [T] = []) {
3030
self.name = name
3131
self.usage = usage
32-
self.default = `default` ?? []
32+
self.default = `default`
3333
}
3434

3535
func register(with argumentParser: ArgumentParser) {

Sources/CLInterface/Argument Types/Protocols.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import SPMUtility
22

3-
// Argument type is on of the types that can be represented by Argument (String, Int, or Bool, optional or not)
3+
// Argument type is one of the types that can be represented by Argument (String, Int, or Bool, optional or not)
44
public protocol ArgumentType {
55
associatedtype Base: SPMUtility.ArgumentKind & BaseArgumentType
66
}
Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11

22
extension Mirror {
3-
static func reflectProperties<T>(
4-
of target: Any,
5-
matchingType type: T.Type = T.self,
6-
using closure: (T) throws -> Void
7-
) rethrows {
8-
let mirror = Mirror(reflecting: target)
9-
10-
for child in mirror.children {
11-
try (child.value as? T).map(closure)
12-
}
3+
static func reflectProperties<T>(of target: Any, matchingType type: T.Type = T.self) -> [T] {
4+
Mirror(reflecting: target).children.compactMap { $0.value as? T }
5+
}
6+
7+
@discardableResult
8+
static func reflectProperties<T, U>(of target: Any, matchingType type: T.Type = T.self, using closure: (T) throws -> U) rethrows -> [U] {
9+
try Mirror.reflectProperties(of: target, matchingType: T.self).map(closure)
1310
}
1411
}

0 commit comments

Comments
 (0)