Files
swiftpm-embedder/Sources/EmbedderTool/CommandLineInvocation.swift
T. R. Bernstein 292a2c859b Scaffold v1.0.0
2026-04-17 01:08:29 +02:00

30 lines
883 B
Swift

import Foundation
struct CommandLineInvocation {
let sourceDirectory: URL
let outputFile: URL
}
extension CommandLineInvocation {
static func parse(_ arguments: [String]) throws -> CommandLineInvocation {
guard arguments.count == 3 else {
throw CommandLineInvocationError.wrongNumberOfArguments(received: arguments.count - 1)
}
return CommandLineInvocation(
sourceDirectory: URL(fileURLWithPath: arguments[1]),
outputFile: URL(fileURLWithPath: arguments[2])
)
}
}
enum CommandLineInvocationError: Error, CustomStringConvertible {
case wrongNumberOfArguments(received: Int)
var description: String {
switch self {
case .wrongNumberOfArguments(let received):
return "expected 2 arguments (source directory, output file); received \(received)"
}
}
}