export type CommandDefinition = {
  name: string;
  description: string;
  appId?: string;
  aliases?: string[];
};

export const commands: CommandDefinition[] = [
  { name: 'help', description: 'Lists available commands.' },
  { name: 'about', description: 'Opens profile.exe.', appId: 'profile', aliases: ['profile'] },
  { name: 'cv', description: 'Opens cv.core.', appId: 'cv' },
  { name: 'workbench', description: 'Opens workbench.sys.', appId: 'workbench' },
  { name: 'opinions', description: 'Opens opinions.safe.', appId: 'opinions' },
  { name: 'everwished', description: 'Opens everwished.hq.', appId: 'everwished' },
  { name: 'charit', description: 'Opens charIT mode.', appId: 'charit' },
  { name: 'ventures', description: 'Opens ventures.map.', appId: 'ventures' },
  { name: 'river', description: 'Opens riverbean.node.', appId: 'riverbean' },
  { name: 'coo', description: 'Opens happycoo.treat.', appId: 'happycoo' },
  { name: 'media', description: 'Opens media.deck.', appId: 'media' },
  { name: 'evidence', description: 'Opens evidence.log.', appId: 'evidence' },
  { name: 'contact', description: 'Opens contact.link.', appId: 'contact' },
  { name: 'terminal', description: 'Opens ianOS Terminal.', appId: 'terminal' },
  { name: 'control', description: 'Opens Control Panel.', appId: 'control' },
  { name: 'simple', description: 'Switches to Simple Mode.' },
  { name: 'boot', description: 'Replays the ianOS boot sequence.' },
  { name: 'verify', description: 'Opens the evidence and verification route.' },
  { name: 'responsibility', description: 'Displays the Responsibility by Design note.' },
  { name: 'no-beige', description: 'Displays the No Beige declaration.', aliases: ['nobeige'] },
  { name: 'gyp', description: 'Displays the GypBops easter egg.' },
  { name: 'duck', description: 'Displays the duck mode easter egg.' }
];

export function findCommand(input: string) {
  const normalised = input.trim().toLowerCase();
  return commands.find(
    (command) => command.name === normalised || command.aliases?.includes(normalised)
  );
}

export const helpText = commands
  .map((command) => `${command.name.padEnd(14, ' ')} ${command.description}`)
  .join('\n');
