Commit a32a0855 authored by Drew's avatar Drew

usage message

parent 47f4d2db
func loadyaml() throws -> [Yaml:Yaml] {
guard let yamlContents = try? String(contentsOfFile: "atbuild.yaml") else { throw AnarchyBuildError.CantParseYaml("Can't load atbuild.yaml") }
let yaml = Yaml.load(yamlContents)
guard let y = yaml.value else { throw AnarchyBuildError.CantParseYaml("atbuild.yaml file didn't parse.") }
guard let dict = y.dictionary else { fatalError("atbuild.yaml does not define a dictionary") }
return dict
}
guard let yamlContents = try? String(contentsOfFile: "atbuild.yaml") else { fatalError("Can't load atbuild.yaml") }
let yaml = Yaml.load(yamlContents)
guard let y = yaml.value else { fatalError("Can't parse YAML") }
guard let dict = y.dictionary else { fatalError("YAML doesnt define a dictionary") }
guard let package = dict["package"]?.dictionary else { fatalError("No package in YAML") }
let version = "0.1.0-dev"
import Foundation
if Process.arguments.count > 1 && Process.arguments[1] == "--help" {
print("atbuild - Anarchy Tools Build Tool \(version)")
print("https://github.com/AnarchyTools")
print("© 2016 Anarchy Tools Contributors.")
print("")
print("Usage:")
print("atbuild [task]")
if let yaml = try? loadyaml() {
if let taskNames = yaml["tasks"]?.dictionary?.keys.map({$0.string!}) {
print(" task: \(Array(taskNames)) ")
}
}
exit(1)
}
let yaml = try! loadyaml()
guard let package = yaml["package"]?.dictionary else { fatalError("No package in YAML") }
guard let name = package["name"]?.string else { fatalError("No package name") }
print("Building package \(name)...")
func runtask(taskName: String) {
guard let task = y.dictionary?["tasks"]?.dictionary else { fatalError("No tasks in YAML") }
guard let task = yaml["tasks"]?.dictionary else { fatalError("No tasks in YAML") }
guard let defaultTask = task[Yaml(stringLiteral: taskName)]?.dictionary else { fatalError("No \(taskName) task in YAML") }
let t = try! Task(yaml: defaultTask, name: taskName)
try! t.run()
......
......@@ -20,6 +20,7 @@
3AED49971C467C4400AC56A8 /* Shell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3AED49961C467C4400AC56A8 /* Shell.swift */; };
3AED49991C4681F600AC56A8 /* atllbuild.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3AED49981C4681F600AC56A8 /* atllbuild.swift */; };
3AED499B1C46923A00AC56A8 /* PlatformPaths.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3AED499A1C46923A00AC56A8 /* PlatformPaths.swift */; };
3AED499D1C4698BC00AC56A8 /* config.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3AED499C1C4698BC00AC56A8 /* config.swift */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
......@@ -49,6 +50,7 @@
3AED49961C467C4400AC56A8 /* Shell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Shell.swift; path = ../src/Shell.swift; sourceTree = SOURCE_ROOT; };
3AED49981C4681F600AC56A8 /* atllbuild.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = atllbuild.swift; path = ../src/atllbuild.swift; sourceTree = SOURCE_ROOT; };
3AED499A1C46923A00AC56A8 /* PlatformPaths.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = PlatformPaths.swift; path = ../src/PlatformPaths.swift; sourceTree = SOURCE_ROOT; };
3AED499C1C4698BC00AC56A8 /* config.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = config.swift; path = ../src/config.swift; sourceTree = SOURCE_ROOT; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
......@@ -89,6 +91,7 @@
3AED49961C467C4400AC56A8 /* Shell.swift */,
3AED49981C4681F600AC56A8 /* atllbuild.swift */,
3AED499A1C46923A00AC56A8 /* PlatformPaths.swift */,
3AED499C1C4698BC00AC56A8 /* config.swift */,
);
path = AnarchyToolsXcode;
sourceTree = "<group>";
......@@ -175,6 +178,7 @@
3AED49991C4681F600AC56A8 /* atllbuild.swift in Sources */,
3AED49971C467C4400AC56A8 /* Shell.swift in Sources */,
3AED49891C466DFD00AC56A8 /* Parser.swift in Sources */,
3AED499D1C4698BC00AC56A8 /* config.swift in Sources */,
3AED49931C4679E800AC56A8 /* Task.swift in Sources */,
3AED498D1C466DFD00AC56A8 /* Yaml.swift in Sources */,
);
......
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