-
First of all: Thanks for such a great django wrapper for typer! I want to add an option callback to my command class. The problem is that I have multiple commands in that class:
and my option belongs to whole command (just like |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @pySilver - Thanks! I moved this over to discussions because I'm sure others will have the same question. You can use either @callback or @initialize (initialize is just an alias for callback that I thought made more sense for class based commands): from django_typer.management import TyperCommand, initialize, command
class Command(TyperCommand):
@initialize()
def init(): ...
@command()
def foo(): ...
@command()
def bar(): ... You can add any common options shared by foo and bar to
|
Beta Was this translation helpful? Give feedback.
Hi @pySilver - Thanks! I moved this over to discussions because I'm sure others will have the same question.
You can use either @callback or @initialize (initialize is just an alias for callback that I thought made more sense for class based commands):
You can add any common options shared by foo and bar to
init
.init
will be invoked first with those options. If you add options that share names with the Django default options you will override them. If you want to suppress any Dj…