Skip to content

Commit

Permalink
Fix sorting of examples with global priority. (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
floitsch authored Feb 22, 2024
1 parent 6fdcf3b commit 9d27d9e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/help-generator_.toit
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,8 @@ class HelpGenerator:
this-examples := command_.examples_.map: | example/Example | [example, path_]
sub-examples := []
add-global-examples_ command_ sub-examples --path=path_ --skip-first-level
sub-examples.sort --in-place: | a/List b/List | a[0].global-priority - b[0].global-priority
// Higher priority examples should come first.
sub-examples.sort --in-place: | a/List b/List | b[0].global-priority.compare-to a[0].global-priority

all-examples := this-examples + sub-examples
if all-examples.is-empty: return
Expand Down
12 changes: 6 additions & 6 deletions tests/help_test.toit
Original file line number Diff line number Diff line change
Expand Up @@ -769,17 +769,17 @@ test-examples:
# Root example 2:
root sub2
# Example 5:
root sub2 global5
# Example 1:
root sub global3
# Example 3:
root sub global1
# Example 6:
root sub2 global1
# Example 1:
root sub global3
# Example 5:
root sub2 global5
"""
actual = build-examples.call [cmd]
expect-equals expected actual

0 comments on commit 9d27d9e

Please sign in to comment.