Commit ac237cb1 authored by Johannes Schriewer's avatar Johannes Schriewer

Merge pull request #88 from AnarchyTools/fix-usage

Fix usage
parents 238cdc1f 71b3fa47
Pipeline #1733 passed with stage
......@@ -81,14 +81,8 @@ overlays.append(contentsOf: Platform.targetPlatform.overlays)
print("enabling overlays \(overlays)")
var package: Package! = nil
do {
package = try Package(filepath: packageFile, overlay: overlays, focusOnTask: focusOnTask)
} catch {
fatalError("Could not load package file: \(error)")
}
//usage message
if Process.arguments.contains("--help") {
func usage() {
print("atbuild - Anarchy Tools Build Tool \(version)")
print("https://github.com/AnarchyTools")
print("© 2016 Anarchy Tools Contributors.")
......@@ -96,13 +90,31 @@ if Process.arguments.contains("--help") {
print("Usage:")
print("atbuild [--toolchain (/toolchain/path | xcode)] [-f packagefile] [task] [--clean]")
print("tasks:")
for (key, task) in package.tasks {
print(" \(key)")
if let p = package {
print("tasks:")
for (key, _) in p.tasks {
print(" \(key)")
}
}
else {
print("No tasks are available; run --help in a directory with a build.atpkg for project-specific help")
}
exit(1)
}
do {
package = try Package(filepath: packageFile, overlay: overlays, focusOnTask: focusOnTask)
} catch {
print("Could not load package file: \(error)")
usage()
}
//usage message
if Process.arguments.contains("--help") {
usage()
}
func runTask(taskName: String, package: Package) {
guard let task = package.tasks[taskName] else { fatalError("No \(taskName) task in build configuration.") }
......@@ -111,6 +123,7 @@ func runTask(taskName: String, package: Package) {
}
}
//choose which task to run
if Process.arguments.count > 1 {
var i = 1
......
Subproject commit 5a80826717205ae146e20addc5c71f486abcd07f
Subproject commit c42d4e01d7bd3cc93bdb0b122ae11bd8f67017f7
......@@ -14,6 +14,15 @@ if ! $ATBUILD atbuild --use-overlay static; then
$ATBUILD atbuild
fi
echo "****************USAGE TEST**************"
cd $DIR/tests/fixtures/nonstandard_package_file
$ATBUILD --help > /tmp/usage.txt || true
if ! grep "Usage:" /tmp/usage.txt; then
echo "Didn't print usage"
exit 1
fi
echo "****************PLUGIN TEST**************"
cd $DIR/tests/fixtures/attool
$ATBUILD > /tmp/plugin.txt
......
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