Skip to content

can't get list of bools using multiple flag #2295

@solarmist

Description

@solarmist

I have an option that is a list of bools, but I'm pairing each boolean value with another multiple option. So I do actually need a list of booleans and not just a count of values because order matters.
I'm not using is_flag, but I assume this translates to the same under the hood.

@click.option(
    "--collection/--single",
    "-c/-s",
    type=bool,
    default=[False],
    count=True,
    help=(
        "Is a file a collection of books? Add once for every file included. "
        "Consumed in order of files."
    ),
)
@click.option(
    "--file",
    "-f",
    required=True,
    type=click.Path(
        exists=True, readable=True, dir_okay=False, allow_dash=True, path_type=str
    ),
    multiple=True,
    help=(
        "The path of the input file.  Note: Every file must be paired with a language. "
        "And the pairs will be processed left to right."
    ),
)

Environment:

Python version: 3.9.7.1
Click version: 8.1.3

Is there an alternative way I should be doing this? If not #2246 breaks my code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions