Skip to content

Commit cc11f95

Browse files
Merge pull request #35 from nikolainobadi/swift-picker-kit
Swift picker kit
2 parents c17d7ef + 71f7c7a commit cc11f95

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+850
-1659
lines changed

Package.resolved

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ let package = Package(
2727
.package(url: "https://github.com/nikolainobadi/NnGitKit.git", from: "0.6.0"),
2828
.package(url: "https://github.com/nikolainobadi/NnShellKit.git", from: "2.0.0"),
2929
.package(url: "https://github.com/nikolainobadi/NnSwiftDataKit", from: "0.5.0"),
30-
.package(url: "https://github.com/nikolainobadi/SwiftPicker.git", from: "1.0.0"),
3130
.package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.5.0"),
31+
.package(url: "https://github.com/nikolainobadi/SwiftPickerKit.git", from: "0.5.0")
3232
],
3333
targets: [
3434
.executableTarget(
3535
name: "nnex",
3636
dependencies: [
3737
"NnexKit",
38-
"SwiftPicker",
38+
.product(name: "SwiftPickerKit", package: "SwiftPickerKit"),
3939
.product(name: "ArgumentParser", package: "swift-argument-parser")
4040
],
4141
linkerSettings: [
@@ -66,7 +66,8 @@ let package = Package(
6666
name: "nnexTests",
6767
dependencies: [
6868
"nnex",
69-
"NnexSharedTestHelpers"
69+
"NnexSharedTestHelpers",
70+
.product(name: "SwiftPickerTesting", package: "SwiftPickerKit")
7071
]
7172
),
7273
.testTarget(

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,11 @@ brew install nikolainobadi/tap/nnex
5050
```
5151

5252
## Commands
53-
**nnex** utilizes four subcommands: `Brew`, `Build`, `Config`, and `Archive`.
53+
**nnex** utilizes four subcommands: `Brew`, `Build`, and `Config`.
5454

5555
- **Brew commands** are used to interact with Homebrew and GitHub
5656
- **Build commands** handle local binary building
5757
- **Config commands** are used to set preferences
58-
- **Archive commands** provide archiving and packaging functionality
5958

6059
The tool follows a clean architecture with separation of concerns between command parsing, business logic, and infrastructure.
6160

@@ -120,7 +119,7 @@ Issues and suggestions are also welcome via [GitHub Issues](https://github.com/n
120119
### Third-Party Libraries
121120

122121
#### My Libraries
123-
- [SwiftPicker](https://github.com/nikolainobadi/SwiftPicker) - Interactive command-line selection interfaces
122+
- [SwiftPickerKit](https://github.com/nikolainobadi/SwiftPickerKit) - Interactive command-line selection interfaces
124123
- [NnGitKit](https://github.com/nikolainobadi/NnGitKit) - Git operations wrapper (GitShellKit)
125124
- [NnShellKit](https://github.com/nikolainobadi/NnShellKit) - Shell command execution utilities
126125
- [NnSwiftDataKit](https://github.com/nikolainobadi/NnSwiftDataKit) - SwiftData utilities and extensions

Sources/NnexKit/Building/ProjectBuilder.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import Foundation
44
public struct ProjectBuilder {
55
private let shell: any Shell
66
private let config: BuildConfig
7-
private let progressDelegate: BuildProgressDelegate?
7+
private let progressDelegate: (any BuildProgressDelegate)?
88

9-
public init(shell: any Shell, config: BuildConfig, progressDelegate: BuildProgressDelegate? = nil) {
9+
public init(shell: any Shell, config: BuildConfig, progressDelegate: (any BuildProgressDelegate)? = nil) {
1010
self.shell = shell
1111
self.config = config
1212
self.progressDelegate = progressDelegate

Sources/NnexKit/Formula/FormulaPublisher.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ import Files
99

1010
/// Handles publishing Homebrew formulas to a specified tap.
1111
public struct FormulaPublisher {
12-
private let gitHandler: GitHandler
12+
private let gitHandler: any GitHandler
1313

1414
/// Initializes a new instance of FormulaPublisher.
1515
/// - Parameter gitHandler: The Git handler used to commit and push formula files.
16-
public init(gitHandler: GitHandler) {
16+
public init(gitHandler: any GitHandler) {
1717
self.gitHandler = gitHandler
1818
}
1919
}

Sources/NnexKit/Git/DefaultGitHandler.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import NnShellKit
1212
/// Default implementation of the GitHandler protocol, providing Git-related operations.
1313
public struct DefaultGitHandler {
1414
private let shell: any Shell
15-
private let gitShell: GitShell
15+
private let gitShell: any GitShell
1616

1717
/// Initializes a new instance of DefaultGitHandler with the specified shell.
1818
/// - Parameter shell: The shell used to execute commands.

Sources/NnexKit/Releasing/ReleaseStore.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77

88
/// Manages the process of uploading a release to a remote repository.
99
public struct ReleaseStore {
10-
private let gitHandler: GitHandler
10+
private let gitHandler: any GitHandler
1111

1212
/// Initializes a new instance of ReleaseStore with a Git handler.
1313
/// - Parameter gitHandler: The Git handler used for managing releases.
14-
public init(gitHandler: GitHandler) {
14+
public init(gitHandler: any GitHandler) {
1515
self.gitHandler = gitHandler
1616
}
1717
}

Sources/NnexKit/Shared/NnexError.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,5 @@ public enum NnexError: Error {
3131
case noPreviousVersionToIncrement
3232

3333
case missingExecutable
34+
case selectionRequired
3435
}

Sources/nnex/Commands/Archive/ArchiveMacOS.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77

88
import Files
99
import NnexKit
10+
import Foundation
1011
import NnShellKit
12+
import SwiftPickerKit
1113
import ArgumentParser
12-
import Foundation
13-
import SwiftPicker
1414

1515
extension Nnex.Archive {
1616
struct MacOS: ParsableCommand {

Sources/nnex/Commands/Brew/ImportTap.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ extension Nnex.Brew {
1919
var path: String?
2020

2121
func run() throws {
22+
let picker = Nnex.makePicker()
2223
let context = try Nnex.makeContext()
23-
let path = try path ?? Nnex.makePicker().getRequiredInput(prompt: "Enter the local path to your Homebrew tap folder.")
24-
let folder = try Folder(path: path)
24+
let folder = try selectHomebrewFolder(path: path, picker: picker)
2525
let tapName = folder.name.removingHomebrewPrefix
2626
let remotePath = try Nnex.makeGitHandler().getRemoteURL(path: folder.path)
2727

@@ -53,6 +53,13 @@ extension Nnex.Brew {
5353

5454
// MARK: - Private Methods
5555
private extension Nnex.Brew.ImportTap {
56+
func selectHomebrewFolder(path: String?, picker: any NnexPicker) throws -> Folder {
57+
if let path {
58+
return try Folder(path: path)
59+
}
60+
61+
return try picker.requiredFolderSelection(prompt: "Select the Homebrew Tap folder you would like to import.")
62+
}
5663
/// Decodes a Homebrew formula from a file.
5764
/// - Parameter file: The file containing the formula.
5865
/// - Returns: A BrewFormula instance if decoding is successful, or nil otherwise.

0 commit comments

Comments
 (0)