Skip to content

Commit 7e29e43

Browse files
committed
Create Sources/Extensions
1 parent 8cc9f4b commit 7e29e43

File tree

5 files changed

+23
-18
lines changed

5 files changed

+23
-18
lines changed

Package.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ let package = Package(
3131
name: "CommentCLI",
3232
dependencies: [
3333
.target(name: "CommentCore"),
34+
.target(name: "Extensions"),
3435
]
3536
),
3637
.target(
@@ -53,6 +54,7 @@ let package = Package(
5354
.product(name: "Yams", package: "Yams"),
5455
.target(name: "CommentCLI"),
5556
]
56-
)
57+
),
58+
.target(name: "Extensions")
5759
]
5860
)

Sources/CommentCLI/Comment.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import Foundation
99
import ArgumentParser
1010
import CommentCore
11+
import Extensions
1112

1213
/// A command-line interface for creating or updating a comment on a GitHub issue or pull request.
1314
package struct Comment: ParsableCommand {
@@ -45,7 +46,7 @@ package struct Comment: ParsableCommand {
4546
print("inputs.owner: \(owner)")
4647
let repo = ProcessInfo.processInfo.environment["REPO"] ?? repo
4748
print("inputs.repo: \(repo)")
48-
let number = try Int(try: ProcessInfo.processInfo.environment["NUMBER"] ?? number)
49+
let number = try Int(string: ProcessInfo.processInfo.environment["NUMBER"] ?? number)
4950
print("inputs.number: \(number)")
5051
let anchor = ProcessInfo.processInfo.environment["ANCHOR"] ?? anchor
5152
print("inputs.anchor: \(anchor)")

Sources/CommentCLI/Int+Ext.swift

Lines changed: 0 additions & 15 deletions
This file was deleted.

Sources/Extensions/Int+Ext.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//
2+
// Int+Ext.swift
3+
//
4+
//
5+
// Created by zwc on 2024/9/7.
6+
//
7+
8+
import Foundation
9+
10+
package extension Int {
11+
init(string: String, line: Int = #line) throws {
12+
guard let int = Int(string) else {
13+
throw NSError(domain: "Required string of integer", code: line)
14+
}
15+
self = int
16+
}
17+
}

Sources/CommentCLI/Task+Ext.swift renamed to Sources/Extensions/Task+Ext.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import Foundation
99

10-
extension Task where Failure == Error {
10+
package extension Task where Failure == Error {
1111
/// Performs an async task in a sync context.
1212
///
1313
/// - Note: This function blocks the thread until the given operation is finished. The caller is responsible for managing multithreading.

0 commit comments

Comments
 (0)