Skip to content

Does Typer support Tuples as Multiple Multi Value Options - List[Tuple[str, str]] - like Click does? #387

Description

@jtfidje

First Check

  • I added a very descriptive title to this issue.
  • I used the GitHub search to find a similar issue and didn't find it.
  • I searched the Typer documentation, with the integrated search.
  • I already searched in Google "How to X in Typer" and didn't find any information.
  • I already read and followed all the tutorial in the docs and didn't find an answer.
  • I already checked if it is not related to Typer but to Click.

Commit to Help

  • I commit to help with one of those options 👆

Example Code

import typer
from typing import List, Tuple

app = typer.Typer()

@app.command()
def test(opts: List[Tuple[str, str]]):
    ...

Description

I'm converting a small Click app to Typer and hit the following issue; I can't seem to get Tuples as Multiple Multi Value Options working.

I would like to achieve the following:

python main.py test --opt "--some-arg" "value" --opt "--another-arg" "value"

This is achieved in Click with the following option:

@click.option(
    "--opt",
    "opts",
    multiple=True,
    type=(str, str),
    required=False,
    default=(),
    help=(
        "Append to current config string. Options are given in the following format: "
        '[--opt "--force" "true" --opt "--overwrite" "true"]'
    ),
)

Operating System

Linux

Operating System Details

No response

Typer Version

0.4.1

Python Version

3.7.3

Additional Context

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions