def _ask_for_datasource_type()

in src/databao_context_engine/cli/add_datasource_config.py [0:0]


def _ask_for_datasource_type() -> DatasourceType:
    supported_types_by_folder = _group_supported_types_by_folder(
        get_all_available_plugin_types(exclude_file_plugins=True)
    )

    all_config_folders = sorted(supported_types_by_folder.keys())
    config_folder = click.prompt(
        "What type of datasource do you want to add?",
        type=click.Choice(all_config_folders),
        default=all_config_folders[0] if len(all_config_folders) == 1 else None,
    )
    click.echo(f"Selected type: {config_folder}")

    all_subtypes_for_folder = sorted(supported_types_by_folder[config_folder])
    config_type = click.prompt(
        "What is the subtype of this datasource?",
        type=click.Choice(all_subtypes_for_folder),
        default=all_subtypes_for_folder[0] if len(all_subtypes_for_folder) == 1 else None,
    )
    click.echo(f"Selected subtype: {config_type}")

    return DatasourceType.from_main_and_subtypes(config_folder, config_type)