Skip to content

Commit 0b2dc1c

Browse files
committed
Create rich panel groups for what is coming from plugin and what is coming from project
1 parent 5171e0b commit 0b2dc1c

File tree

6 files changed

+20
-12
lines changed

6 files changed

+20
-12
lines changed

toolit/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Public API for the package."""
22

3-
from .config import get_config_value
4-
from .decorators import tool
3+
from toolit.config import get_config_value
4+
from toolit.decorators import tool
55

66
__all__ = [
77
"get_config_value",

toolit/auto_loader.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import pathlib
1414
import importlib
1515
import importlib.metadata
16-
from toolit.constants import MARKER_TOOL, ToolitTypesEnum
16+
from toolit.constants import MARKER_TOOL, RichHelpPanelNames, ToolitTypesEnum
1717
from toolit.create_apps_and_register import register_command
1818
from types import FunctionType, ModuleType
1919
from typing import Any, Callable
@@ -56,7 +56,7 @@ def load_tools_from_plugins() -> list[FunctionType]:
5656
"""Discover and return plugin commands via entry points."""
5757
plugins = get_plugin_tools()
5858
for plugin in plugins:
59-
register_command(plugin, rich_help_panel="Commands from Plugins")
59+
register_command(plugin, rich_help_panel=RichHelpPanelNames.NAME_OF_THE_RICH_GROUP_HELP_PANEL_PLUGINS)
6060
return plugins
6161

6262

@@ -83,7 +83,7 @@ def load_tools_from_folder(folder_path: pathlib.Path) -> list[FunctionType]:
8383
tool_groups: list[FunctionType] = get_items_from_folder(folder_path, tool_group_strategy)
8484
# Register each tool as a command
8585
for tool in tools:
86-
register_command(tool, rich_help_panel="Commands Local Tools")
86+
register_command(tool, rich_help_panel=RichHelpPanelNames.NAME_OF_THE_RICH_GROUP_HELP_PANEL_PROJECT)
8787
return tools + tool_groups
8888

8989

toolit/cli.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
"""CLI entry point for the toolit package."""
2-
from .auto_loader import load_tools_from_folder, load_tools_from_plugins, register_command
3-
from .config import load_devtools_folder
4-
from .create_apps_and_register import app
5-
from .create_tasks_json import create_vscode_tasks_json
2+
from toolit.auto_loader import load_tools_from_folder, load_tools_from_plugins, register_command
3+
from toolit.config import load_devtools_folder
4+
from toolit.constants import RichHelpPanelNames
5+
from toolit.create_apps_and_register import app
6+
from toolit.create_tasks_json import create_vscode_tasks_json
67

78
load_tools_from_folder(load_devtools_folder())
89
load_tools_from_plugins()
9-
register_command(create_vscode_tasks_json)
10+
register_command(create_vscode_tasks_json, rich_help_panel=RichHelpPanelNames.NAME_OF_THE_RICH_GROUP_HELP_PANEL_PLUGINS)
1011

1112

1213
if __name__ == "__main__":

toolit/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111
import toml
1212
import pathlib
13-
from .constants import ConfigFileKeys
1413
from functools import lru_cache
14+
from toolit.constants import ConfigFileKeys
1515
from typing import Callable, overload
1616

1717

toolit/constants.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55
MARKER_TOOL = "__toolit_tool_type__"
66

77

8+
class RichHelpPanelNames:
9+
"""Namespace for the different rich help panel names."""
10+
11+
NAME_OF_THE_RICH_GROUP_HELP_PANEL_PROJECT = "Commands from Project"
12+
NAME_OF_THE_RICH_GROUP_HELP_PANEL_PLUGINS = "Commands from Plugins"
13+
14+
815
class ConfigFileKeys:
916
"""Namespace for the different configuration file keys for user configuration."""
1017

toolit/decorators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Decorator to tell if a function is a tool."""
22

3-
from .constants import MARKER_TOOL, ToolitTypesEnum
3+
from toolit.constants import MARKER_TOOL, ToolitTypesEnum
44
from typing import Any, Callable, TypeVar
55

66
T = TypeVar("T", bound=Callable[..., Any])

0 commit comments

Comments
 (0)