'Defines a new command line option.
If ``type`` is given (one of str, float, int, datetime, or timedelta)
or can be inferred from the ``default``, we parse the command line
arguments based on the given type. If ``multiple`` is True, we accept
comma-separated values, and the option value is always a list.
For multi-value integers, we also accept the syntax ``x:y``, which
turns into ``range(x, y)`` - very useful for long integer ranges.
``help`` and ``metavar`` are used to construct the
automatically generated command line help string. The help
message is formatted like::
--name=METAVAR      help string
``group`` is used to group the defined options in logical
groups. By default, command line options are grouped by the
file in which they are defined.
Command line option names must be unique globally. They can be parsed
from the command line with `parse_command_line` or parsed from a
config file with `parse_config_file`.
If a ``callback`` is given, it will be run with the new value whenever
the option is changed.  This can be used to combine command-line
and file-based options::
define("config", type=str, help="path to config file",
callback=lambda path: parse_config_file(path, final=False))
With this definition, options in the file specified by ``--config`` will
override options set earlier on the command line, but can be overridden
by later flags.'

def define(self, name, default=None, type=None, help=None, metavar=None, multiple=False, group=None, callback=None):

    normalized = self._normalize_name(name)
    if (normalized in self._options):
        raise Error(('Option    %r    already    defined    in    %s' % (normalized, self._options[normalized].file_name)))
    frame = sys._getframe(0)
    options_file = frame.f_code.co_filename
    if ((frame.f_back.f_code.co_filename == options_file) and (frame.f_back.f_code.co_name == 'define')):
        frame = frame.f_back
    file_name = frame.f_back.f_code.co_filename
    if (file_name == options_file):
        file_name = ''
    if (type is None):
        if ((not multiple) and (default is not None)):
            type = default.__class__
        else:
            type = str
    if group:
        group_name = group
    else:
        group_name = file_name
    option = _Option(name, file_name=file_name, default=default, type=type, help=help, metavar=metavar, multiple=multiple, group_name=group_name, callback=callback)
    self._options[normalized] = option
