Commit 3e5f5122 authored by Drew's avatar Drew

Run non-default tasks via CLI argument

parent 358d4708
......@@ -2,6 +2,6 @@ package:
name: "atbuild"
tasks:
default:
helloworld:
tool: "shell"
script: "echo \"Hello world\""
\ No newline at end of file
script: "echo \"Hello world\""
......@@ -6,8 +6,16 @@ guard let package = dict["package"]?.dictionary else { fatalError("No package in
guard let name = package["name"]?.string else { fatalError("No package name") }
print("Building package \(name)...")
//todo: run non-default tasks
guard let task = y.dictionary?["tasks"]?.dictionary else { fatalError("No tasks in YAML") }
guard let defaultTask = task["default"]?.dictionary else { fatalError("No default task in YAML") }
let t = try! Task(yaml: defaultTask, name: "default")
try! t.run()
\ No newline at end of file
func runtask(taskName: String) {
guard let task = y.dictionary?["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()
}
if Process.arguments.count > 1 {
runtask(Process.arguments[1])
}
else {
runtask("default")
}
......@@ -62,6 +62,12 @@
ReferencedContainer = "container:AnarchyToolsXcode.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<CommandLineArguments>
<CommandLineArgument
argument = "helloworld"
isEnabled = "YES">
</CommandLineArgument>
</CommandLineArguments>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
......
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