<plugin identifier>:<command> => plugin:<plugin identifier> command
This commit is contained in:
1 parent
ec491c3d0d
commit
c6f1088ccf
2 files changed
+28
-11
No files matched your search
@@ -27,6 +27,7 @@ class OctoPrintPluginCommands(click.MultiCommand):
|
||||
The :class:`~octoprint.plugin.core.PluginManager` instance.
|
||||
"""
|
||||
|
||||
prefix = "plugin"
|
||||
sep = ":"
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
@@ -75,12 +76,17 @@ class OctoPrintPluginCommands(click.MultiCommand):
|
||||
|
||||
for name, hook in self.hooks.items():
|
||||
try:
|
||||
plugin_info = self.plugin_manager.get_plugin_info(name, require_enabled=False)
|
||||
command_group = click.Group(name=name, help="{} commands".format(plugin_info.name))
|
||||
|
||||
commands = hook(self, pass_octoprint_ctx)
|
||||
for command in commands:
|
||||
if not isinstance(command, click.Command):
|
||||
self._logger.warn("Plugin {} provided invalid CLI command, ignoring it: {!r}".format(name, command))
|
||||
continue
|
||||
result[name + self.sep + command.name] = command
|
||||
command_group.add_command(command)
|
||||
|
||||
result[self.prefix + self.sep + name] = command_group
|
||||
except:
|
||||
self._logger.exception("Error while retrieving cli commants for plugin {}".format(name))
|
||||
|
||||
|
||||
Reference in new issue
Block a user