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

Public Member Functions

def __init__ (self, param_decls=None, show_default=False, prompt=False, confirmation_prompt=False, hide_input=False, is_flag=None, flag_value=None, multiple=False, count=False, allow_from_autoenv=True, type=None, help=None, hidden=False, show_choices=True, show_envvar=False, **attrs)
 
def add_to_parser (self, parser, ctx)
 
def get_help_record (self, ctx)
 
def get_default (self, ctx)
 
def prompt_for_value (self, ctx)
 
def resolve_envvar_value (self, ctx)
 
def value_from_envvar (self, ctx)
 
def full_process_value (self, ctx, value)
 
- Public Member Functions inherited from Parameter
def __init__ (self, param_decls=None, type=None, required=False, default=None, callback=None, nargs=None, metavar=None, expose_value=True, is_eager=False, envvar=None, autocompletion=None)
 
def __repr__ (self)
 
def human_readable_name (self)
 
def make_metavar (self)
 
def consume_value (self, ctx, opts)
 
def type_cast_value (self, ctx, value)
 
def process_value (self, ctx, value)
 
def value_is_missing (self, value)
 
def handle_parse_result (self, ctx, opts, args)
 
def get_usage_pieces (self, ctx)
 
def get_error_hint (self, ctx)
 

Data Fields

 prompt
 
 confirmation_prompt
 
 hide_input
 
 hidden
 
 default
 
 is_flag
 
 flag_value
 
 type
 
 is_bool_flag
 
 count
 
 multiple
 
 allow_from_autoenv
 
 help
 
 show_default
 
 show_choices
 
 show_envvar
 
- Data Fields inherited from Parameter
 secondary_opts
 
 type
 
 required
 
 callback
 
 nargs
 
 multiple
 
 expose_value
 
 default
 
 is_eager
 
 metavar
 
 envvar
 
 autocompletion
 

Static Public Attributes

string param_type_name = "option"
 
- Static Public Attributes inherited from Parameter
string param_type_name = "parameter"
 

Detailed Description

Options are usually optional values on the command line and
have some extra features that arguments don't have.

All other parameters are passed onwards to the parameter constructor.

:param show_default: controls if the default value should be shown on the
                     help page. Normally, defaults are not shown. If this
                     value is a string, it shows the string instead of the
                     value. This is particularly useful for dynamic options.
:param show_envvar: controls if an environment variable should be shown on
                    the help page.  Normally, environment variables
                    are not shown.
:param prompt: if set to `True` or a non empty string then the user will be
               prompted for input.  If set to `True` the prompt will be the
               option name capitalized.
:param confirmation_prompt: if set then the value will need to be confirmed
                            if it was prompted for.
:param hide_input: if this is `True` then the input on the prompt will be
                   hidden from the user.  This is useful for password
                   input.
:param is_flag: forces this option to act as a flag.  The default is
                auto detection.
:param flag_value: which value should be used for this flag if it's
                   enabled.  This is set to a boolean automatically if
                   the option string contains a slash to mark two options.
:param multiple: if this is set to `True` then the argument is accepted
                 multiple times and recorded.  This is similar to ``nargs``
                 in how it works but supports arbitrary number of
                 arguments.
:param count: this flag makes an option increment an integer.
:param allow_from_autoenv: if this is enabled then the value of this
                           parameter will be pulled from an environment
                           variable in case a prefix is defined on the
                           context.
:param help: the help string.
:param hidden: hide this option from help outputs.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  param_decls = None,
  show_default = False,
  prompt = False,
  confirmation_prompt = False,
  hide_input = False,
  is_flag = None,
  flag_value = None,
  multiple = False,
  count = False,
  allow_from_autoenv = True,
  type = None,
  help = None,
  hidden = False,
  show_choices = True,
  show_envvar = False,
**  attrs 
)

Member Function Documentation

◆ add_to_parser()

def add_to_parser (   self,
  parser,
  ctx 
)

Reimplemented from Parameter.

◆ full_process_value()

def full_process_value (   self,
  ctx,
  value 
)

Reimplemented from Parameter.

◆ get_default()

def get_default (   self,
  ctx 
)
Given a context variable this calculates the default value.

Reimplemented from Parameter.

◆ get_help_record()

def get_help_record (   self,
  ctx 
)

Reimplemented from Parameter.

◆ prompt_for_value()

def prompt_for_value (   self,
  ctx 
)
This is an alternative flow that can be activated in the full
value processing if a value does not exist.  It will prompt the
user until a valid value exists and then returns the processed
value as result.

◆ resolve_envvar_value()

def resolve_envvar_value (   self,
  ctx 
)

Reimplemented from Parameter.

◆ value_from_envvar()

def value_from_envvar (   self,
  ctx 
)

Reimplemented from Parameter.

Field Documentation

◆ allow_from_autoenv

allow_from_autoenv

◆ confirmation_prompt

confirmation_prompt

◆ count

count

◆ default

default

◆ flag_value

flag_value

◆ help

help

◆ hidden

hidden

◆ hide_input

hide_input

◆ is_bool_flag

is_bool_flag

◆ is_flag

is_flag

◆ multiple

multiple

◆ param_type_name

string param_type_name = "option"
static

◆ prompt

prompt

◆ show_choices

show_choices

◆ show_default

show_default

◆ show_envvar

show_envvar

◆ type

type

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