Skip to content

Commit

Permalink
Add Arena.init with params
Browse files Browse the repository at this point in the history
  • Loading branch information
finestructure committed Mar 13, 2020
1 parent 6b865ed commit 0070c8a
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions Sources/ArenaCore/ArenaCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,16 @@ import ShellOut


public enum ArenaError: LocalizedError {
case invalidPath(String)
case missingDependency
case pathExists(String)
case noLibrariesFound
case noSourcesFound

public var errorDescription: String? {
switch self {
case .invalidPath(let path):
return "'\(path)' is not a valid path"
case .missingDependency:
return "provide at least one dependency"
case .pathExists(let path):
Expand Down Expand Up @@ -78,6 +81,33 @@ public struct Arena: ParsableCommand {
}


extension Arena {
public init(projectName: String,
libNames: [String],
platform: Platform,
force: Bool,
outputPath: String,
skipOpen: Bool,
book: Bool,
dependencies: [Dependency]) throws {

guard let path = Path(outputPath) else {
throw ArenaError.invalidPath(outputPath)
}

self.projectName = projectName
self.libNames = libNames
self.platform = platform
self.force = force
self.outputPath = path
self.showVersion = false
self.skipOpen = skipOpen
self.book = book
self.dependencies = dependencies
}
}


extension Arena {
var targetName: String { projectName }

Expand Down

0 comments on commit 0070c8a

Please sign in to comment.