Skip to content

How to define command-level option when using multicommand class? #134

Answered by bckohan
pySilver asked this question in Q&A
Discussion options

You must be logged in to vote

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 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…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@pySilver
Comment options

Answer selected by bckohan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested
2 participants
Converted from issue

This discussion was converted from issue #133 on October 24, 2024 16:50.