scragg0x / realms-wiki

Git based wiki inspired by Gollum
http://realms.io
GNU General Public License v2.0
833 stars 91 forks source link

Fix CLI registration for module command groups. fix #103 #159

Closed gazpachoking closed 7 years ago

gazpachoking commented 7 years ago

It seems commands registered by submodules got a little bit borked by bd41eaac4ef9b8e154558cfa7993f0d46acdb434 Instead of modules creating click groups that later got registered, they started calling the AppGroup().group method, which already registered them under the 'cli' subcommand name, and each successive module cli command would overwrite the last.

I wasn't sure the way we wanted to solve it, but I figured we didn't want the modules just auto-registering themselves on import (do we?) I made a realms.cli_group decorator that modules can use to declare create their command group (like the click.group function, but sets cls=AppGroup,) and then the application registers the command during discovery phase. Since the context is now being opened externally, I also stripped that bit out of search's rebuild_index command. I also added the ability for modules to declare a CLI group name different than their module name if desired.