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

Explicit category order #96

Open
cspotcode opened this issue Aug 20, 2021 · 1 comment
Open

Explicit category order #96

cspotcode opened this issue Aug 20, 2021 · 1 comment

Comments

@cspotcode
Copy link

When you have an "Advanced" command category, you often want that category to appear last in --help. However, it will be alphabetized first.

It would be nice to offer a way to explicitly order command categories and, when #35 is implemented, option categories.

For command categories, perhaps cli.orderCategories([array of category names]) is sufficient.

For option categories, we could accept a similar array on the Usage object, or we could accept an option new Cli({alphabetizeOptions: false}) and document categories in the order they are declared on a command, similar to how positionals are ordered based on declaration order.

@cspotcode
Copy link
Author

Thinking out loud, the orderCategories option feels more obvious and straightforward. The array can be declared once, then imported anywhere it is needed.

export const categoryGeneral = 'Options';
export const categoryAdvanced = 'Advanced';
export const categories = [ categoryGeneral, categoryAdvanced ];
import {Categories} from './core';
class Foo extends Command {
  static usage: Usage = {
    categories // name it "categories" instead of "orderCategories" to be terser?
  }
}

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

No branches or pull requests

1 participant