// Bitbucket Data Center 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.

use bitbucket_dc_mcp::core::config_manager::load_config;

struct VersionRow {
    label: &'static str,
    is_default: bool,
}

// mcpify:versions:begin
const KNOWN_VERSIONS: &[VersionRow] = &[
    VersionRow {
        label: "10.3",
        is_default: true,
    },
    VersionRow {
        label: "10.2",
        is_default: false,
    },
    VersionRow {
        label: "10.0",
        is_default: false,
    },
    VersionRow {
        label: "9.6",
        is_default: false,
    },
    VersionRow {
        label: "9.5",
        is_default: false,
    },
    VersionRow {
        label: "9.4",
        is_default: false,
    },
    VersionRow {
        label: "9.3",
        is_default: false,
    },
    VersionRow {
        label: "9.2",
        is_default: false,
    },
    VersionRow {
        label: "9.1",
        is_default: false,
    },
    VersionRow {
        label: "9.0",
        is_default: false,
    },
    VersionRow {
        label: "8.19",
        is_default: false,
    },
    VersionRow {
        label: "8.18",
        is_default: false,
    },
    VersionRow {
        label: "8.17",
        is_default: false,
    },
    VersionRow {
        label: "8.16",
        is_default: false,
    },
    VersionRow {
        label: "8.15",
        is_default: false,
    },
    VersionRow {
        label: "8.14",
        is_default: false,
    },
    VersionRow {
        label: "8.13",
        is_default: false,
    },
    VersionRow {
        label: "8.12",
        is_default: false,
    },
    VersionRow {
        label: "8.11",
        is_default: false,
    },
    VersionRow {
        label: "8.10",
        is_default: false,
    },
    VersionRow {
        label: "8.9",
        is_default: false,
    },
    VersionRow {
        label: "8.8",
        is_default: false,
    },
    VersionRow {
        label: "8.7",
        is_default: false,
    },
    VersionRow {
        label: "8.6",
        is_default: false,
    },
    VersionRow {
        label: "8.5",
        is_default: false,
    },
    VersionRow {
        label: "8.4",
        is_default: false,
    },
    VersionRow {
        label: "8.3",
        is_default: false,
    },
    VersionRow {
        label: "8.2",
        is_default: false,
    },
    VersionRow {
        label: "8.1",
        is_default: false,
    },
    VersionRow {
        label: "8.0",
        is_default: false,
    },
];
// mcpify:versions:end

pub fn run() -> anyhow::Result<()> {
    let active_version = load_config(serde_json::Map::new())
        .map(|config| config.api_version)
        .unwrap_or_default();

    for row in KNOWN_VERSIONS {
        let mut markers = Vec::new();
        if row.is_default {
            markers.push("default");
        }
        if row.label == active_version {
            markers.push("active");
        }
        if markers.is_empty() {
            println!("{}", row.label);
        } else {
            println!("{} ({})", row.label, markers.join(", "));
        }
    }
    Ok(())
}
