import fs from 'fs-extra';
import path from 'path';

interface Config {
  defaultDirectory: string;
  version: string;
}

export async function getConfig(): Promise<Config> {
  const homeDir = process.env.HOME || process.env.USERPROFILE;
  const configFile = path.join(homeDir!, '.im-disclaimer', 'config.json');
  
  try {
    return await fs.readJson(configFile);
  } catch (error) {
    throw new Error('Configuration not found. Please run setup first.');
  }
}

export async function getDefaultDirectory(): Promise<string> {
  const config = await getConfig();
  return path.resolve(process.cwd(), config.defaultDirectory);
}
