This PR contains the work done to create the root folder of a new project when executing the _colibri_ executable. In addition, some other work has been done: * added the `ArgumentParser` package dependency to the package; * implemented the `FileService` service in the _library_ target; * implemented the `CreateRootFolderTask` task in the _library_ target; * removed some unnecessary comments and boilerplate code; Reviewed-on: #2 Co-authored-by: Javier Cicchelli <javier@rock-n-code.com> Co-committed-by: Javier Cicchelli <javier@rock-n-code.com>
42 lines
929 B
Swift
42 lines
929 B
Swift
import Foundation
|
|
|
|
@testable import ColibriLibrary
|
|
|
|
final class FileServiceSpy {
|
|
|
|
// MARK: Properties
|
|
|
|
private(set) var isCreateFolderCalled: Bool = false
|
|
private(set) var isDeleteCalled: Bool = false
|
|
private(set) var isExistsAtCalled: Bool = false
|
|
private(set) var urlCalled: URL?
|
|
|
|
}
|
|
|
|
// MARK: - FileServicing
|
|
|
|
extension FileServiceSpy: FileServicing {
|
|
var currentFolder: URL {
|
|
get async { .someCurrentFolder }
|
|
}
|
|
|
|
func createFolder(at url: URL) async throws(FileServiceError) {
|
|
isCreateFolderCalled = true
|
|
urlCalled = url
|
|
}
|
|
|
|
func delete(at url: URL) async throws(FileServiceError) {
|
|
isDeleteCalled = true
|
|
urlCalled = url
|
|
}
|
|
|
|
@discardableResult
|
|
func exists(at url: URL) async throws(FileServiceError) -> Bool {
|
|
isExistsAtCalled = true
|
|
urlCalled = url
|
|
|
|
return .random()
|
|
}
|
|
|
|
}
|