Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add flagSortOrder to help options #896

Merged
merged 5 commits into from
Dec 15, 2023
Merged

Conversation

mdonnalley
Copy link
Contributor

Adds flagSortOrder to helpOptions

Two options:

  • alphabetical: Sort flags alphabetically. All flags with short characters will come first. (Default behavior)
  • none: Do not sort flags. They will appear in the order in which they were defined on the command.

To use, add flagSortOrder to helpOptions in your CLI's package.json

"oclif": {
  "helpOptions": {
    "flagSortOrder": "none"
  }
}

Fixes oclif/oclif#1214

@W-14626665@

cristiand391
cristiand391 previously approved these changes Dec 14, 2023
@cristiand391
Copy link
Member

QA notes:

✅ no option defined, defaults to sorted
oclif.helpOptions.flagSortOrder = none, unsorted
oclif.helpOptions.flagSortOrder = none, sorted

🟡 sort order option isn't validated at runtime:
while in TS only alphabetical or none is supported, this config is read from json so any typos make it render flags as unsorted.

Screenshot 2023-12-14 at 12 01 08

do you think it's worth validating this at runtime? not sure it should throw or warn (also don't know if oclif validates any psjon settings).

@mdonnalley mdonnalley merged commit 3903720 into main Dec 15, 2023
58 checks passed
@mdonnalley mdonnalley deleted the mdonnalley/flag-sort-order branch December 15, 2023 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Respect order of flags
2 participants