// {{ display_name }} MCP server — generated by mcpify. Do not hand-edit.
//
// v8 multi-version support: lists the OpenAPI spec versions this project
// currently has a store for (added at `generate`/`mcpify add-version` time),
// showing which is the default/latest and which is active for this process.

import type { Command } from 'commander';

import { loadConfig } from '../core/config-manager.js';

interface VersionRow {
  label: string;
  isDefault: boolean;
}

// mcpify:versions:begin
const KNOWN_VERSIONS: VersionRow[] = [
{%- for v in version_entries %}
  { label: '{{ v.label }}', isDefault: {{ v.label == default_version_label }} },
{%- endfor %}
];
// mcpify:versions:end

export function registerVersionsCommand(program: Command): void {
  program
    .command('versions')
    .description('List the API spec versions available in this project')
    .action(() => {
      const activeVersion = loadConfig().api_version;
      for (const row of KNOWN_VERSIONS) {
        const markers = [row.isDefault ? 'default' : null, row.label === activeVersion ? 'active' : null].filter(
          Boolean,
        );
        console.log(markers.length > 0 ? `${row.label} (${markers.join(', ')})` : row.label);
      }
    });
}
