/**
 * @module commands/shopify/theme
 * @description Command definitions for working with Shopify themes
 */

import { Command } from "commander";
import { initShopifyTheme } from "./init.js";
import { dev } from "./dev.js";
import { createTestConnectionCommand } from "./test-connection.js";

/**
 * Creates and configures the theme command group
 *
 * @returns The configured theme command with all subcommands
 *
 * @example
 * ```typescript
 * // Add the theme command to a parent command
 * const program = new Command();
 * program.addCommand(createThemeCommand());
 * ```
 */
export function createThemeCommand(): Command {
  const command = new Command("theme").description(
    "Commands for working with Shopify themes"
  );

  // Add init command
  command
    .command("init")
    .description("Initialize a new Shopify theme")
    .option(
      "-n, --name <n>",
      "Name of the theme directory to create",
      "my-theme"
    )
    .option("-f, --force", "Overwrite directory if it exists")
    .option(
      "-o, --output-dir <path>",
      "Directory where the theme will be created (defaults to current directory)"
    )
    .option("--debug", "Enable debug mode with verbose logging", false)
    .action(async (options) => {
      await initShopifyTheme({
        name: options.name,
        force: options.force,
        outputDir: options.outputDir,
        debug: options.debug,
      });
    });

  // Add dev command
  command.addCommand(dev);

  // Add test connection command
  command.addCommand(createTestConnectionCommand());

  // Here, you can add more theme-related commands in the future
  // For example:
  // command.command('dev')...

  return command;
}
