execute method
Execute the command.
Implementation
@override
Future<CommandResult> execute(String args, ToolUseContext context) async {
final tokens = args.trim().split(RegExp(r'\s+'));
if (tokens.isEmpty || tokens.first.isEmpty) {
return const TextCommandResult(
'Usage: /mcp-xaa <setup|login|show|clear>\n\n'
'Subcommands:\n'
' setup - Configure the IdP connection\n'
' login - Cache an IdP id_token\n'
' show - Show the current IdP connection config\n'
' clear - Clear the IdP connection config',
);
}
final subcommand = tokens.first;
final subArgs = tokens.length > 1 ? tokens.sublist(1) : <String>[];
switch (subcommand) {
case 'setup':
return _handleSetup(subArgs);
case 'login':
return _handleLogin(subArgs);
case 'show':
return _handleShow();
case 'clear':
return _handleClear();
default:
return TextCommandResult(
'Unknown subcommand: $subcommand\n'
'Usage: /mcp-xaa <setup|login|show|clear>',
);
}
}