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

Add aliases support for sub commands #627

Merged
merged 1 commit into from
Apr 30, 2024
Merged

Commits on Apr 23, 2024

  1. Add aliases support for sub commands

    This adds support for aliases for subcommands via a new parameter to
    CommandConfigurations constructors. The aliases are passed as an array
    of strings, where the default is just an empty array that signifies there
    are no aliases. The aliases are supported regardless of if a different
    commandName is chosen or not. This also updates how subcommands show up
    in the help text. Any aliases are now displayed to the right of the original
    command.
    
    In addition to the functionality itself, this change:
    
    1. Updates some of the EndToEnd parsing tests to make sure they function
    while using aliases.
    2. Sprinkles mentions where I saw fit in the documentation.
    3. Updates the Math example to have aliases for `math stats average`
    (`math stats avg`), and `math multiply` (`math mul`).
    
    `math`'s help text now looks like the below:
    
    ```
    ~ math --help
    OVERVIEW: A utility for performing maths.
    
    USAGE: math <subcommand>
    
    OPTIONS:
      --version               Show the version.
      -h, --help              Show help information.
    
    SUBCOMMANDS:
      add (default)           Print the sum of the values.
      multiply, mul           Print the product of the values.
      stats                   Calculate descriptive statistics.
    
      See 'math help <subcommand>' for detailed help.
    
    ~ math stats --help
    OVERVIEW: Calculate descriptive statistics.
    
    USAGE: math stats <subcommand>
    
    OPTIONS:
      --version               Show the version.
      -h, --help              Show help information.
    
    SUBCOMMANDS:
      average, avg            Print the average of the values.
      stdev                   Print the standard deviation of the values.
      quantiles               Print the quantiles of the values (TBD).
    
      See 'math help stats <subcommand>' for detailed help.
    ```
    
    and use of the aliases:
    
    ```
    ~ math mul 10 10
    100
    
    ~ math stats avg 10 20
    15.0
    ```
    
    This change does NOT add any updates to the shell completion logic for
    this feature.
    
    Fixes apple#248
    dcantah committed Apr 23, 2024
    Configuration menu
    Copy the full SHA
    891e893 View commit details
    Browse the repository at this point in the history