mattallty / Caporal.js

A full-featured framework for building command line applications (cli) with node.js
MIT License
3.44k stars 97 forks source link

Grouping commands into sections #189

Open donmccurdy opened 4 years ago

donmccurdy commented 4 years ago

Is your feature request related to a problem? Please describe.

My CLI has a growing number of commands that work independently — I don't think they make sense as subcommands— and they start to look overwhelming when presented as a list.

Describe the solution you'd like I'd love to be able to group my commands into sections in the --help output, without changing how they're invoked. Maybe with help text associated with each section, but that's just a nice-to-have. For example:

USAGE

    ▸ gltf-transform <command> [ARGUMENTS...] [OPTIONS...]

  COMMANDS — Type 'gltf-transform help <command>' to get some help about a command

    GENERAL — Inspect, copy, and combine files.

    inspect                              Inspect the contents of the model
    list                                 List a model's resources of a given type
    repack                               Rewrites the model with minimal changes

    MODIFY — Enhance or alter file content.

    ao                                   Bakes per-vertex ambient occlusion
    colorspace                           Colorspace correction for vertex colors
    prune                                Prunes duplicate binary resources
    split                                Splits mesh data into separate .bin files
    unlit                                Converts materials to an unlit, shadeless model

    OPTIMIZE — Optimize file for runtime performance.

    quantize                                   Quantize geometry and animation data
    resample                                   Resample animations at a given FPS

    COMPRESS — Compress file for transmission.

    ktx                                   Compress textures with KTX
    draco                                   Compress geometry with Draco
    gzip                                   Compress the entire file with gzip

  GLOBAL OPTIONS

    -h, --help                           Display global help or command-related help.
    -V, --version                        Display version.
    -v, --verbose                        Verbose mode: will also output debug messages.

Describe alternatives you've considered

Tried .help() and the sectionName option. Does the right thing, but not for the content I want to group. :)

Context

https://gltf-transform.donmccurdy.com/

Would you be able to work on it and provide a pull request ?

donmccurdy commented 4 years ago

I more or less solved my own problem using emoji, so feel free to close this. 🙂

Screen Shot 2020-07-09 at 6 22 22 PM

beorn commented 4 years ago

I think it'd still be nice to be able to group commands like you suggested.

donmccurdy commented 4 years ago

Don't know if this is a good idea necessarily, but I've got a nicer visual result now by using empty commands and newlines as section dividers:

Screen Shot 2020-08-27 at 4 21 23 PM