Commit bff4dd97 authored by Drew's avatar Drew

Improve package sorting when calling --help

parent b7d14425
......@@ -104,7 +104,22 @@ func usage() {
if let p = package {
print("tasks:")
for (key, _) in p.tasks {
for (key, _) in p.tasks.sorted(by: {
let lp = $0.0.value.package, rp = $0.1.value.package
//sort the outer package on top
if lp.name == p.name && rp.name != p.name {return true }
if lp.name != p.name && rp.name == p.name {return false}
//sort other packages alphabetically
if lp.name != rp.name {
return lp.name < rp.name
}
//within a package, sort the "default" task first
if $0.0.value.unqualifiedName == "default" && $0.1.value.unqualifiedName != "default" { return true }
if $0.0.value.unqualifiedName != "default" && $0.1.value.unqualifiedName == "default" { return false }
//sort remaining tasks by name
return $0.0.key < $0.1.key}
) {
print(" \(key)")
}
}
......
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