canonical / craft-application

The basis for *craft applications
https://canonical-craft-application.readthedocs-hosted.com/en/latest
GNU Lesser General Public License v3.0
7 stars 12 forks source link

Groups added via Application.add_command_group() should get merged with the defaults #94

Closed tigarmo closed 1 year ago

tigarmo commented 1 year ago

Bug Description

Calling Application.add_command_group() to add a CommandGroup whose name matches one the default groups causes the groups to stay duplicated, which affects the help output.

To Reproduce

In this example, rockcraft has an init command in the Other group:

$ rockcraft --help
Usage:
    rockcraft [help] <command>

Summary:    A tool to create OCI images

Global options:
       -h, --help:  Show this help message and exit
    -v, --verbose:  Show debug information and be more verbose
      -q, --quiet:  Only show warnings and errors, not progress
      --verbosity:  Set the verbosity level to 'quiet', 'brief',
                    'verbose', 'debug' or 'trace'
    -V, --version:  Show the application version and exit

Starter commands:
          version:  Show the application version and exit

Commands can be classified as follows:
       Extensions:  expand-extensions, list-extensions
        Lifecycle:  build, clean, pack, prime, pull, stage
            Other:  version
            Other:  init

For more information about a command, run 'rockcraft help <command>'.
For a summary of all commands, run 'rockcraft help --all'.

See that there are two rows for "Other:"

part yaml

n/a

Relevant log output

n/a
tigarmo commented 1 year ago

My immediate thought is to leave add_command_group() untouched and merge the groups in the command_groups property.