Commit fc0017b7 authored by Drew's avatar Drew

Add softFail, an argument for atpm to use

atpm needs to parse packages that refer to overlays in imported packages before those imported overlays are available

Don't treat those as hard failures
parent dd9b13be
......@@ -192,7 +192,7 @@ final public class Package {
- parameter overlay: A list of overlays to apply globally to all tasks in the package.
- parameter focusOnTask: The user has "selected" the particular task. We provide more diagnostics for this task.
*/
public convenience init(filepath: Path, overlay: [String], focusOnTask: String?) throws {
public convenience init(filepath: Path, overlay: [String], focusOnTask: String?, softFail: Bool = false) throws {
//todo: why doesn't this throw?
guard let parser = try Parser(filepath: filepath) else {
......@@ -201,15 +201,16 @@ final public class Package {
let result = try parser.parse()
let basepath = filepath.dirname()
try self.init(type: result, overlay: overlay, pathOnDisk:basepath, focusOnTask: focusOnTask)
try self.init(type: result, overlay: overlay, pathOnDisk:basepath, focusOnTask: focusOnTask, softFail: softFail)
}
/**
- parameter overlay: The names of things to overlay.
- parameter pathOnDisk: The path to the file on disk. This does not include the file name.
- parameter focusOnTask: The user has "selected" the particular task. We provide more diagnostics for this task.
- parameter softFail: Don't fail hard on certain kinds of errors that may occur if dependencies are not fetched
*/
public init(type: ParseType, overlay requestedGlobalOverlays: [String], pathOnDisk: Path, focusOnTask: String?) throws {
public init(type: ParseType, overlay requestedGlobalOverlays: [String], pathOnDisk: Path, focusOnTask: String?, softFail: Bool = false) throws {
//warn on unknown keys
for (k,_) in type.properties {
if !Key.allKeys.map({$0.rawValue}).contains(k) {
......@@ -374,7 +375,14 @@ final public class Package {
for overlayName in task.overlay {
if task.appliedOverlays.contains(overlayName) { continue }
guard let overlay = declaredOverlays[overlayName] else {
fatalError("Can't find overlay named \(overlayName) in \(declaredOverlays)")
if softFail {
let proposedWarning = "Warning: Can't find overlay named \(overlayName) in \(declaredOverlays); run atpm fetch"
if !warnings.contains(proposedWarning) { warnings.append(proposedWarning) }
continue
}
else {
fatalError("Can't find overlay named \(overlayName) in \(declaredOverlays)")
}
}
again = again || task.applyOverlay(name: overlayName, overlay: overlay, globalOverlays: requestedGlobalOverlays)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment