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] Global option anywhere in the command line? #166

Closed
4 tasks done
trondth opened this issue Sep 14, 2020 · 4 comments
Closed
4 tasks done

[QUESTION] Global option anywhere in the command line? #166

trondth opened this issue Sep 14, 2020 · 4 comments
Labels
answered question Further information is requested

Comments

@trondth
Copy link

trondth commented Sep 14, 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

Is it possible to implement a global option so it can be added anywhere in the commandline and to be displayed in the help for each subcommand.

Additional context

It is well documented how to create a global option with callback, but it seems to have some limitations. It seems to me that a global option «foo» can only be set like this:

command --foo bar subcommand

but not like this:

command subcommand --foo bar

And also, the help for «foo» will only be displayed on:

command --help

not

command subcommand --help

Is there a way to make the global option more flexible?

@trondth trondth added the question Further information is requested label Sep 14, 2020
@rino0601
Copy link

IMO,
Duplicate of #153

@trondth
Copy link
Author

trondth commented Oct 23, 2020

IMO,
Duplicate of #153

Yes. Reading the last reply in #153, I agree. (I first mistook it for sharing options between a subset of commands)

@tiangolo
Copy link
Owner

tiangolo commented Nov 9, 2022

In that case, we can continue in that issue, right?

Sorry for the long delay! 🙈 I wanted to personally address each issue/PR and they piled up through time, but now I'm checking each one in order.

@trondth
Copy link
Author

trondth commented Nov 10, 2022

Yes, I should have closed this back in 2020. Thanks for the feedback.

In that case, we can continue in that issue, right?

Sorry for the long delay! see_no_evil I wanted to personally address each issue/PR and they piled up through time, but now I'm checking each one in order.

@trondth trondth closed this as completed Nov 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
answered question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants