import { readdir } from "node:fs/promises";
import * as path from "node:path";
import chalk from "chalk";

import { commandHandler, helpers } from "../core";
import { ASSETS_FOLDER, PROFILES_FOLDER } from "../consts";

import type { ProfileFile } from "./types";
import type { Command } from "../core";

const syncUpCommand: Command = {
  name: "sync-up",
  description: "Syncs up all assets folders with the manifest. Usage: sync-up",
  execute: async (args: string[]) => {
    const profileName = args.slice(1).join(" ");

    const profiles = await helpers.profile.getAll();
    const profile = profiles.find((profile) => profile.name === profileName);
    if (!profile) {
      console.log(chalk.red(`Profile "${profileName}" not found`));
      return;
    }
  },
};

commandHandler.registerCommand(syncUpCommand);
