run method

  1. @override
bool run()
override

Runs this command.

The return value is wrapped in a Future if necessary and returned by CommandRunner.runCommand.

Implementation

@override
bool run() {
  // A specific repository tool can be inspected by name even without a
  // workspace; the full dump only includes them when a workspace is set.
  final rest = argResults!.rest;
  final withRepo = argResults!['workspace'] != null || rest.isNotEmpty;
  final tools = _listedTools(withRepo);

  if (rest.isNotEmpty) {
    final wanted = _normalizeToolName(rest.first);
    final tool = tools.where((t) => t.name == wanted).firstOrNull;
    if (tool == null) {
      throw StateError(
        'Unknown tool: ${rest.first}. Known: ${_allKnownToolNames.join(', ')}',
      );
    }
    print(_json.convert(tool.inputSchema));
  } else {
    print(_json.convert({for (final t in tools) t.name: t.inputSchema}));
  }
  return true;
}