class PluginsInfoTool implements Tool {

    @Override
    public void run(CommandLine line, ToolRunningContext context) throws Exception {
        Collection<PluginInfo> pluginInfos = Plugins.getPluginInfos();
        Writer writer = new OutputStreamWriter(context.getOutputStream());
        AsciiTableFormatterFactory asciiTableFormatterFactory = new AsciiTableFormatterFactory();

        try (TableFormatter formatter = asciiTableFormatterFactory.create(writer, "Plugins", new TableFormatterConfig(),
                new Column("Plugin type name"),
                new Column("Available plugin IDs"))) {

            for (PluginInfo p : pluginInfos) {
                List<String> ids = Plugins.getPluginImplementationsIds(p);
                String strIds = String.join(", ", ids);
                if (strIds.length() > MAX_IDS_LENGTH) {
                    formatter.writeCell(p.getPluginName());
                    formatter.writeCell(ids.get(0));
                    for (int i = 1; i < ids.size(); ++i) {
                        formatter.writeEmptyCell();
                        formatter.writeCell(ids.get(i));
                    }
                } else {
                    formatter.writeCell(p.getPluginName());
                    formatter.writeCell(strIds);
                }
            }
        } catch (IOException e) {
            throw new UncheckedIOException(e);
        }
    }

}