import type { CommandContext } from "../types.js";
import { CommandModule } from "../types.js";

const helpFlags = [
  {
    flag: "--command=NAME",
    description: "Choose which command to run (default: seed).",
  },
  {
    flag: "--help / -h",
    description: "Show this help message.",
  },
];

export const helpCommand: CommandModule = {
  name: "help",
  description: "Show available commands and their options.",
  flags: helpFlags,
  handler: async ({ commands }: CommandContext) => {
    console.log("Usage: npm start -- --command=<command> [options]");
    console.log("\nAvailable commands:");
    for (const command of commands) {
      console.log(`  ${command.name} — ${command.description}`);
      if (command.flags.length) {
        for (const flag of command.flags) {
          console.log(`    ${flag.flag} — ${flag.description}`);
        }
      }
    }
  },
};
