import { Select } from '@inkjs/ui';
import { Box, Text } from 'ink';
import type { Option } from '@inkjs/ui';

const options = [
    { label: 'Generate types', value: 'generate' },
    { label: 'Create a config (init)', value: 'init' },
] as const satisfies Option[];

type Command = (typeof options)[number]['value'];

export interface CommandPickerProps {
    onPick: (cmd: Command) => void;
}

export function CommandPicker(props: CommandPickerProps) {
    return (
        <Box flexDirection="column">
            <Text>What do you want to do?</Text>
            <Select options={options} onChange={(value) => props.onPick(value as Command)} />
        </Box>
    );
}
