import { createInterface, type Interface } from "node:readline";
import { stdin, stdout } from 'node:process'
import { getCommands } from "./commands.js";

export type CLICommand = {
  name: string,
  description: string,
  callback: (state: State) => void;
}

export type State = {
  readline: Interface,
  commands: Record<string, CLICommand>;
}

export function initState() {
  const rl = createInterface({
    input: stdin,
    output: stdout,
    prompt: 'Pokedex > ',
  });

  return {
    readline: rl,
    commands: getCommands(),
  };

}
