Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a way to override the options of a command? #406

Open
7 tasks done
nidhaloff opened this issue Jun 18, 2022 · 1 comment
Open
7 tasks done

Is there a way to override the options of a command? #406

nidhaloff opened this issue Jun 18, 2022 · 1 comment
Labels
question Question or problem

Comments

@nidhaloff
Copy link

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 hi(name: str):
   print("hi ", name)

# I want to do something like this
app.get_command("hi").options["name"] = typer.Option(..., hidden=True)

# Basically, I want to dynamically manipulate the options of a specific command. Is something like this achievable?

Description

I have a use case, where I want to override the typer command options. Basically, after decorating a function as typer.command()
I want to manipulate the options of this certain command later. Is this possible? I included a minimal example of what I want to do.

Operating System

Linux

Operating System Details

ubuntu 20.04

Typer Version

0.4.1

Python Version

3.8

Additional Context

No response

@nidhaloff nidhaloff added the question Question or problem label Jun 18, 2022
@david-alm
Copy link

david-alm commented Jul 5, 2022

From the sidelines: It's generally best practice to pose some minimal version of your specific usecase in issues so as not to fall into the trap of the xy problem.

Though perhaps you could use a callback to solve this issue?
You could, based on the context, modify app commands and call them with variable numbers of parameters?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question or problem
Projects
None yet
Development

No branches or pull requests

2 participants