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

[QUESTION] How to implement global options. #42

Closed
3 of 4 tasks
shmokmt opened this issue Jan 22, 2020 · 5 comments
Closed
3 of 4 tasks

[QUESTION] How to implement global options. #42

shmokmt opened this issue Jan 22, 2020 · 5 comments
Labels
question Question or problem

Comments

@shmokmt
Copy link

shmokmt commented Jan 22, 2020

First check

  • 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 searched in Google "How to X in Click" and didn't find any information.

Description

How can I implement global options like --install-completion, --show-completion?

Click allows to easily implement global options in context.
I want a simple function similar to typer.

Additional context

I often implement global options such as --env and --debug.

@shmokmt shmokmt added the question Question or problem label Jan 22, 2020
@thedrow
Copy link

thedrow commented Jan 29, 2020

By inspecting the code it seems like this is not possible right now.
How do we imagine such API?

@euri10
Copy link

euri10 commented Feb 3, 2020

By inspecting the code it seems like this is not possible right now.
How do we imagine such API?

I'd be tempted to say like in click with a group decorator, so as to stay in familiar territory :)

I tried various stuff with the add_typer command without being able to achieve the desired result.
That would be awesome to get an answer.

This is the main blocker identified for us so far switching from click as we make quite a fair use of global switches, most often for logging

@dedsm
Copy link

dedsm commented Mar 17, 2020

I imagine this as an option in the app ie Typer instances, that way it'd work even without subcommands

@tiangolo
Copy link
Owner

Thanks for the discussion here everyone!

Here are the new docs for using is_eager: https://typer.tiangolo.com/tutorial/options/version/ 🎉

And here for adding global CLI options: https://typer.tiangolo.com/tutorial/commands/callback/ 🚀

@shmokmt
Copy link
Author

shmokmt commented Mar 21, 2020

Thank you so much 😄

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

5 participants