OpenQuizz
Une application de gestion des contenus pédagogiques
MultiCommand Class Reference
Inheritance diagram for MultiCommand:
Collaboration diagram for MultiCommand:

Public Member Functions

def __init__ (self, name=None, invoke_without_command=False, no_args_is_help=None, subcommand_metavar=None, chain=False, result_callback=None, **attrs)
 
def collect_usage_pieces (self, ctx)
 
def format_options (self, ctx, formatter)
 
def resultcallback (self, replace=False)
 
def format_commands (self, ctx, formatter)
 
def parse_args (self, ctx, args)
 
def invoke (self, ctx)
 
def resolve_command (self, ctx, args)
 
def get_command (self, ctx, cmd_name)
 
def list_commands (self, ctx)
 
- Public Member Functions inherited from Command
def __init__ (self, name, context_settings=None, callback=None, params=None, help=None, epilog=None, short_help=None, options_metavar="[OPTIONS]", add_help_option=True, no_args_is_help=False, hidden=False, deprecated=False)
 
def get_usage (self, ctx)
 
def get_params (self, ctx)
 
def format_usage (self, ctx, formatter)
 
def get_help_option_names (self, ctx)
 
def get_help_option (self, ctx)
 
def make_parser (self, ctx)
 
def get_help (self, ctx)
 
def get_short_help_str (self, limit=45)
 
def format_help (self, ctx, formatter)
 
def format_help_text (self, ctx, formatter)
 
def format_epilog (self, ctx, formatter)
 
- Public Member Functions inherited from BaseCommand
def __init__ (self, name, context_settings=None)
 
def __repr__ (self)
 
def make_context (self, info_name, args, parent=None, **extra)
 
def main (self, args=None, prog_name=None, complete_var=None, standalone_mode=True, **extra)
 
def __call__ (self, *args, **kwargs)
 

Data Fields

 no_args_is_help
 
 invoke_without_command
 
 subcommand_metavar
 
 chain
 
 result_callback
 
- Data Fields inherited from Command
 callback
 
 params
 
 help
 
 epilog
 
 options_metavar
 
 short_help
 
 add_help_option
 
 no_args_is_help
 
 hidden
 
 deprecated
 
- Data Fields inherited from BaseCommand
 name
 
 context_settings
 

Static Public Attributes

bool allow_extra_args = True
 
bool allow_interspersed_args = False
 
- Static Public Attributes inherited from BaseCommand
bool allow_extra_args = False
 
bool allow_interspersed_args = True
 
bool ignore_unknown_options = False
 

Detailed Description

A multi command is the basic implementation of a command that
dispatches to subcommands.  The most common version is the
:class:`Group`.

:param invoke_without_command: this controls how the multi command itself
                               is invoked.  By default it's only invoked
                               if a subcommand is provided.
:param no_args_is_help: this controls what happens if no arguments are
                        provided.  This option is enabled by default if
                        `invoke_without_command` is disabled or disabled
                        if it's enabled.  If enabled this will add
                        ``--help`` as argument if no arguments are
                        passed.
:param subcommand_metavar: the string that is used in the documentation
                           to indicate the subcommand place.
:param chain: if this is set to `True` chaining of multiple subcommands
              is enabled.  This restricts the form of commands in that
              they cannot have optional arguments but it allows
              multiple commands to be chained together.
:param result_callback: the result callback to attach to this multi
                        command.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  name = None,
  invoke_without_command = False,
  no_args_is_help = None,
  subcommand_metavar = None,
  chain = False,
  result_callback = None,
**  attrs 
)

Member Function Documentation

◆ collect_usage_pieces()

def collect_usage_pieces (   self,
  ctx 
)
Returns all the pieces that go into the usage line and returns
it as a list of strings.

Reimplemented from Command.

◆ format_commands()

def format_commands (   self,
  ctx,
  formatter 
)
Extra format methods for multi methods that adds all the commands
after the options.

◆ format_options()

def format_options (   self,
  ctx,
  formatter 
)
Writes all the options into the formatter if they exist.

Reimplemented from Command.

◆ get_command()

def get_command (   self,
  ctx,
  cmd_name 
)
Given a context and a command name, this returns a
:class:`Command` object if it exists or returns `None`.

Reimplemented in FlaskGroup, CommandCollection, and Group.

◆ invoke()

def invoke (   self,
  ctx 
)
Given a context, this invokes the attached callback (if it exists)
in the right way.

Reimplemented from Command.

◆ list_commands()

def list_commands (   self,
  ctx 
)
Returns a list of subcommand names in the order they should
appear.

Reimplemented in CommandCollection, Group, and FlaskGroup.

◆ parse_args()

def parse_args (   self,
  ctx,
  args 
)
Given a context and a list of arguments this creates the parser
and parses the arguments, then modifies the context as necessary.
This is automatically invoked by :meth:`make_context`.

Reimplemented from Command.

◆ resolve_command()

def resolve_command (   self,
  ctx,
  args 
)

◆ resultcallback()

def resultcallback (   self,
  replace = False 
)
Adds a result callback to the chain command.  By default if a
result callback is already registered this will chain them but
this can be disabled with the `replace` parameter.  The result
callback is invoked with the return value of the subcommand
(or the list of return values from all subcommands if chaining
is enabled) as well as the parameters as they would be passed
to the main callback.

Example::

    @click.group()
    @click.option('-i', '--input', default=23)
    def cli(input):
return 42

    @cli.resultcallback()
    def process_result(result, input):
return result + input

.. versionadded:: 3.0

:param replace: if set to `True` an already existing result
        callback will be removed.

Field Documentation

◆ allow_extra_args

bool allow_extra_args = True
static

◆ allow_interspersed_args

bool allow_interspersed_args = False
static

◆ chain

chain

◆ invoke_without_command

invoke_without_command

◆ no_args_is_help

no_args_is_help

◆ result_callback

result_callback

◆ subcommand_metavar

subcommand_metavar

The documentation for this class was generated from the following file: