diff --git a/Package.resolved b/Package.resolved index 2e6852c..9438f89 100644 --- a/Package.resolved +++ b/Package.resolved @@ -24,8 +24,8 @@ "repositoryURL": "https://github.com/g-Off/XcodeProject.git", "state": { "branch": null, - "revision": "de0150084afc079464675f01f936924cceba4604", - "version": "0.5.0-alpha.3" + "revision": "aa649c9d1056b46e56b933aac43324a9e7dd6872", + "version": "0.5.0-alpha.4" } } ] diff --git a/Package.swift b/Package.swift index c447b8f..4a4d230 100644 --- a/Package.swift +++ b/Package.swift @@ -2,35 +2,27 @@ import PackageDescription let package = Package( - name: "Xcoder", + name: "Xcoder", platforms: [ .macOS(.v10_14) ], products: [ .executable( name: "xcoder", - targets: ["xcoder"]), - .library( - name: "XcoderKit", - targets: ["XcoderKit"]), - ], - dependencies: [ - .package(url: "https://github.com/g-Off/XcodeProject.git", from: "0.5.0-alpha.4"), - .package(url: "https://github.com/g-Off/CommandRegistry.git", from: "0.1.0") - ], + targets: ["xcoder"] + ), + ], + dependencies: [ + .package(url: "https://github.com/g-Off/XcodeProject.git", from: "0.5.0-alpha.4"), + .package(url: "https://github.com/g-Off/CommandRegistry.git", from: "0.1.2") + ], targets: [ .target( name: "xcoder", - dependencies: [ - "XcoderKit" - ] - ), - .target( - name: "XcoderKit", dependencies: [ "XcodeProject", "CommandRegistry" ] - ) + ), ] ) diff --git a/Sources/XcoderKit/Commands/BuildPhaseSortCommand.swift b/Sources/xcoder/Commands/BuildPhaseSortCommand.swift similarity index 99% rename from Sources/XcoderKit/Commands/BuildPhaseSortCommand.swift rename to Sources/xcoder/Commands/BuildPhaseSortCommand.swift index 114d9e6..e2a1581 100644 --- a/Sources/XcoderKit/Commands/BuildPhaseSortCommand.swift +++ b/Sources/xcoder/Commands/BuildPhaseSortCommand.swift @@ -6,9 +6,7 @@ // import Foundation -import Utility import XcodeProject -import Basic import CommandRegistry public struct BuildPhaseSortCommand: Command { diff --git a/Sources/XcoderKit/Commands/CompletionToolCommand.swift b/Sources/xcoder/Commands/CompletionToolCommand.swift similarity index 97% rename from Sources/XcoderKit/Commands/CompletionToolCommand.swift rename to Sources/xcoder/Commands/CompletionToolCommand.swift index 881e800..de561ce 100644 --- a/Sources/XcoderKit/Commands/CompletionToolCommand.swift +++ b/Sources/xcoder/Commands/CompletionToolCommand.swift @@ -6,8 +6,6 @@ // import Foundation -import Utility -import Basic import CommandRegistry public struct CompletionToolCommand: Command { diff --git a/Sources/XcoderKit/Commands/GroupSortCommand.swift b/Sources/xcoder/Commands/GroupSortCommand.swift similarity index 98% rename from Sources/XcoderKit/Commands/GroupSortCommand.swift rename to Sources/xcoder/Commands/GroupSortCommand.swift index b9333e5..ca0ff9e 100644 --- a/Sources/XcoderKit/Commands/GroupSortCommand.swift +++ b/Sources/xcoder/Commands/GroupSortCommand.swift @@ -6,9 +6,7 @@ // import Foundation -import Utility import XcodeProject -import Basic import CommandRegistry public struct GroupSortCommand: Command { diff --git a/Sources/xcoder/Commands/SaveCommand.swift b/Sources/xcoder/Commands/SaveCommand.swift new file mode 100644 index 0000000..4c7930b --- /dev/null +++ b/Sources/xcoder/Commands/SaveCommand.swift @@ -0,0 +1,40 @@ +// +// SaveCommand.swift +// XcoderKit +// +// Created by Geoffrey Foster on 2019-05-02. +// + +import Foundation +import XcodeProject +import CommandRegistry + +public struct SaveCommand: Command { + private struct SaveArguments { + var xcodeproj: AbsolutePath = localFileSystem.currentWorkingDirectory! + } + + public let command: String = "save" + public let overview: String = "Saves the Xcode project." + private let binder = ArgumentBinder() + + public init(parser: ArgumentParser) { + let subparser = parser.add(subparser: command, overview: overview) + binder.bind(positional: subparser.add(positional: "xcodeproj", kind: PathArgument.self, optional: false, usage: "Xcode Project file.", completion: .filename)) { (syncArguments, xcodeproj) in + syncArguments.xcodeproj = xcodeproj.path + } + } + + public func run(with parsedArguments: ArgumentParser.Result) throws { + var arguments = SaveArguments() + try binder.fill(parseResult: parsedArguments, into: &arguments) + + let projectFile: ProjectFile + do { + projectFile = try ProjectFile(url: Foundation.URL(fileURLWithPath: arguments.xcodeproj.asString)) + } catch { + throw Error.invalidProject(path: arguments.xcodeproj.asString) + } + try projectFile.save() + } +} diff --git a/Sources/XcoderKit/Commands/SyncCommand.swift b/Sources/xcoder/Commands/SyncCommand.swift similarity index 98% rename from Sources/XcoderKit/Commands/SyncCommand.swift rename to Sources/xcoder/Commands/SyncCommand.swift index acc7ba6..0b0a30f 100644 --- a/Sources/XcoderKit/Commands/SyncCommand.swift +++ b/Sources/xcoder/Commands/SyncCommand.swift @@ -6,8 +6,6 @@ // import Foundation -import Utility -import Basic import XcodeProject import CommandRegistry diff --git a/Sources/XcoderKit/Error.swift b/Sources/xcoder/Error.swift similarity index 100% rename from Sources/XcoderKit/Error.swift rename to Sources/xcoder/Error.swift diff --git a/Sources/XcoderKit/ArgumentKindExtensions.swift b/Sources/xcoder/Extensions/ArgumentKindExtensions.swift similarity index 93% rename from Sources/XcoderKit/ArgumentKindExtensions.swift rename to Sources/xcoder/Extensions/ArgumentKindExtensions.swift index a88dcfd..0403205 100644 --- a/Sources/XcoderKit/ArgumentKindExtensions.swift +++ b/Sources/xcoder/Extensions/ArgumentKindExtensions.swift @@ -6,7 +6,7 @@ // import Foundation -import Utility +import CommandRegistry extension Foundation.URL: ArgumentKind { public static let completion: ShellCompletion = .filename diff --git a/Sources/XcoderKit/PBXObject+Extensions.swift b/Sources/xcoder/Extensions/PBXObject+Extensions.swift similarity index 100% rename from Sources/XcoderKit/PBXObject+Extensions.swift rename to Sources/xcoder/Extensions/PBXObject+Extensions.swift diff --git a/Sources/XcoderKit/XcodeProjectLoading.swift b/Sources/xcoder/Extensions/XcodeProjectLoading.swift similarity index 98% rename from Sources/XcoderKit/XcodeProjectLoading.swift rename to Sources/xcoder/Extensions/XcodeProjectLoading.swift index fa853df..f4e3d6d 100644 --- a/Sources/XcoderKit/XcodeProjectLoading.swift +++ b/Sources/xcoder/Extensions/XcodeProjectLoading.swift @@ -6,9 +6,8 @@ // import Foundation -import Basic -import Utility import XcodeProject +import CommandRegistry protocol XcodeProjectLoading { var xcodeproj: AbsolutePath { get set } diff --git a/Sources/XcoderKit/XcodeReferenceSorting.swift b/Sources/xcoder/Extensions/XcodeReferenceSorting.swift similarity index 97% rename from Sources/XcoderKit/XcodeReferenceSorting.swift rename to Sources/xcoder/Extensions/XcodeReferenceSorting.swift index 38bbaf7..c64e4e9 100644 --- a/Sources/XcoderKit/XcodeReferenceSorting.swift +++ b/Sources/xcoder/Extensions/XcodeReferenceSorting.swift @@ -6,9 +6,8 @@ // import Foundation -import Basic -import Utility import XcodeProject +import CommandRegistry extension PBXReference.SortOption: StringEnumArgument { static var options: [(name: String, description: String)] = [ diff --git a/Sources/xcoder/Version.swift b/Sources/xcoder/Version.swift index d7559a6..0e9fb3d 100644 --- a/Sources/xcoder/Version.swift +++ b/Sources/xcoder/Version.swift @@ -1,5 +1,5 @@ -import Utility +import CommandRegistry extension Version { - static var current: Version = "0.3.3" + static var current: Version = "0.3.5" } diff --git a/Sources/xcoder/main.swift b/Sources/xcoder/main.swift index 10470d2..c2764e8 100644 --- a/Sources/xcoder/main.swift +++ b/Sources/xcoder/main.swift @@ -1,7 +1,5 @@ -import XcoderKit import Foundation import CommandRegistry -import Utility var registry = Registry(usage: " ", overview: "", version: Version.current) registry.register(command: CompletionToolCommand.self)