MCPcopy Create free account
hub / github.com/IBM/mcp-cli / execute

Method execute

src/mcp_cli/commands/theme/theme.py:84–155  ·  view source on GitHub ↗

Execute the theme command.

(self, **kwargs)

Source from the content-addressed store, hash-verified

82 return CommandMode.CHAT | CommandMode.INTERACTIVE
83
84 async def execute(self, **kwargs) -> CommandResult:
85 """Execute the theme command."""
86 from mcp_cli.utils.preferences import get_preference_manager
87 from chuk_term.ui import output
88
89 pref_manager = get_preference_manager()
90 theme_name = kwargs.get("theme_name")
91
92 # Handle positional argument
93 if not theme_name and "args" in kwargs:
94 args_val = kwargs["args"]
95 if isinstance(args_val, list):
96 theme_name = args_val[0] if args_val else None
97 elif isinstance(args_val, str):
98 theme_name = args_val
99
100 if theme_name:
101 # Set new theme
102 available_themes = [
103 "default",
104 "dark",
105 "light",
106 "minimal",
107 "terminal",
108 "monokai",
109 "dracula",
110 "solarized",
111 ]
112
113 if theme_name not in available_themes:
114 return CommandResult(
115 success=False,
116 error=f"Invalid theme: {theme_name}. Available themes: {', '.join(available_themes)}",
117 )
118
119 # Apply theme
120 set_theme(theme_name)
121
122 # Save preference
123 pref_manager.set_theme(theme_name)
124
125 output.success(f"Theme changed to: {theme_name}")
126
127 return CommandResult(
128 success=True,
129 output=f"Theme changed to: {theme_name}",
130 )
131 else:
132 # Show current theme and available themes
133 current_theme = pref_manager.get_theme()
134 available_themes = [
135 "default",
136 "dark",
137 "light",
138 "minimal",
139 "terminal",
140 "monokai",
141 "dracula",

Callers

nothing calls this directly

Calls 6

get_preference_managerFunction · 0.90
CommandResultClass · 0.90
set_themeMethod · 0.80
successMethod · 0.80
get_themeMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected