diff --git a/src/wuttjamaican/commands/base.py b/src/wuttjamaican/commands/base.py index 0fee315..0a974f9 100644 --- a/src/wuttjamaican/commands/base.py +++ b/src/wuttjamaican/commands/base.py @@ -161,16 +161,16 @@ class Command: self.stdout = stdout or sys.stdout self.stderr = stderr or sys.stderr - # nb. default entry point is like 'wutta-poser.subcommands' - self.subcommands = subcommands or load_entry_points(f'{self.name}.subcommands') + # nb. default entry point is like 'wutta_poser.subcommands' + safe_name = self.name.replace('-', '_') + self.subcommands = subcommands or load_entry_points(f'{safe_name}.subcommands') if not self.subcommands: # nb. legacy entry point is like 'wutta_poser.commands' - safe_name = self.name.replace('-', '_') self.subcommands = load_entry_points(f'{safe_name}.commands') if self.subcommands: msg = (f"entry point group '{safe_name}.commands' uses deprecated name; " - f"please define '{self.name}.subcommands' instead") + f"please define '{safe_name}.subcommands' instead") warnings.warn(msg, DeprecationWarning, stacklevel=2) log.warning(msg) @@ -337,14 +337,16 @@ class Subcommand: way of another entry point in your ``setup.cfg`` file. As with top-level commands, you can "alias" the same subcommand so - it appears under multiple top-level commands: + it appears under multiple top-level commands. Note that if the + top-level command name contains a hyphen, that must be replaced + with underscore for sake of the subcommand entry point: .. code-block:: ini [options.entry_points] poser.subcommands = hello = poser.commands:Hello - wutta-poser.subcommands = + wutta_poser.subcommands = hello = poser.commands:Hello Next time your (``poser``) package is installed, the subcommand