Skip to content

How to use the flag_value option properly? #330

Description

@archiif

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 typer import Argument, Option


def main(
    const_option: str = Option(
        "foo",
        "--const_option",
        is_flag=True,
        flag_value="bar",
    ),
):
    print(const_option)


if __name__ == "__main__":
    typer.run(main)

Description

What I expect:

C:\>script
foo

C:\>script --const_option
bar

What happens:

C:\>script
bar

C:\>script --const_option
bar

Not sure what I am doing wrong here, can someone point me to the right direction?

Operating System

Windows

Operating System Details

No response

Typer Version

0.4.0

Python Version

Python 3.9.4

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionQuestion or problem

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions