tiangolo / typer

Typer, build great CLIs. Easy to code. Based on Python type hints.

Home Page:https://typer.tiangolo.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is there a way to input arguments of a command in a different order in which they are defined?

itsadityagupta opened this issue · comments

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

app = typer.Typer()

@app.command()
def test(arg1: str, arg2: str):
    print(arg1+" "+arg2)

if __name__ == '__main__':
    app()

Description

In the example code above, I have a test command which takes 2 arguments i.e. arg1 and arg2. The command to run this is:

python <filename.py> test value1 value2 where arg1 = value1 and arg2 = value2.

But I want to check if it's possible to provide the value of arg2 first, and then the value for arg1? I tried running the command:

python <filename.py> test arg2=value2 arg1=value1 but it's not working.

For the above command, typer is considering "arg2=value2" as the value for arg1 and "arg1=value1" as the value for arg2.

Operating System

Windows

Operating System Details

No response

Typer Version

0.6.1

Python Version

3.9.12

Additional Context

No response

In that case you probably need CLI Options: https://typer.tiangolo.com/tutorial/options/

Assuming the original issue was solved, it will be automatically closed now. But feel free to add more comments or create new issues.