import fs from "fs";

export default async function getSubcommandsInFolder(path: string, indent: string = "") {
    const files = fs.readdirSync(path, { withFileTypes: true }).filter(
        file => !file.name.endsWith(".ts") && !file.name.endsWith(".map")
    );
    const subcommands = [];
    const subcommandGroups = [];
    let errors = 0;
    for (const file of files) {
        if (file.name === "_meta.js") continue;
        try {
            if (file.isDirectory()) {
                // Get the _meta.ts file
                subcommandGroups.push(await import(`../../../${path}/${file.name}/_meta.js`));
            } else if (file.name.endsWith(".js")) {
                // If its a file
                console.log(`│  ${indent}├─ Loading subcommand ${file.name}`)
                subcommands.push(await import(`../../../${path}/${file.name}`));
            }
        } catch (e) {
            console.error(`│  ${indent}│  └─ Error loading ${file.name}: ${e}`);
            errors++;
        }
    }
    return {subcommands, subcommandGroups, errors};
}
