Skip to content
Myr

WYSIWYG sort (#1400)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* Use simpler more WYSIWYG sort of options * Do a WYSIWYG style sort

authored by John Gee · committed by GitHub · parent 689d7a0 · Browse files · 2 files+29 added−18 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+29 added−18 removed

  • tests:+24 added−13 removed
  • other:+5 added−5 removed

2 files+29 added−18 removed

modified:tests/help.sortOptions.test.js+24 added-13 removed
modified:index.js+5 added-5 removed
65 unmodified lines
66 }67 visibleOptions.push(helpOption);68 }69 if (this.sortOptions) {70 const getSortKey = (option) => {71 // WYSIWYG for order displayed in help with short before long, no special handling for negated.72 return option.short ? option.short.replace(/^-/, '') : option.long.replace(/^--/, '');73 };74 visibleOptions.sort((a, b) => {71 const compare = a.attributeName().localeCompare(b.attributeName());72 if (compare === 0) {73 return (a.negate) ? +1 : -1;74 }75 return compare;75 return getSortKey(a).localeCompare(getSortKey(b));76 });77 }78 return visibleOptions;79 }
2093 unmodified lines