export const extractArgumentsFromConfigs = (configs) => {
    if (!configs)
        return {};
    return Object.fromEntries(Object.entries(configs)
        .filter(([_name, def]) => def.argument)
        .map(([name, def]) => [
        name,
        {
            description: def.description,
            scope: def.scope,
            choices: def.choices,
            ...def.argument,
        },
    ]));
};
export const convertConfigToOption = (name, config) => {
    const { cli } = config;
    const type = cli?.type ?? config.internal?.type;
    if (!type && config?.internal)
        return undefined;
    const choices = config.choices?.map(choice => (typeof choice === 'string' ? choice : choice.value));
    return {
        ...cli,
        name: cli?.name ?? name,
        default: config.default ?? cli?.default,
        description: config.description ?? cli?.description,
        env: config.cli?.env,
        choices,
        scope: config.scope,
        type: type,
    };
};
