summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--click/core.py18
-rw-r--r--docs/advanced.rst4
-rw-r--r--docs/commands.rst4
-rw-r--r--docs/documentation.rst4
-rw-r--r--examples/complex/complex/cli.py4
-rw-r--r--tests/test_normalization.py8
6 files changed, 21 insertions, 21 deletions
diff --git a/click/core.py b/click/core.py
index b168e52..7d70d0b 100644
--- a/click/core.py
+++ b/click/core.py
@@ -359,21 +359,21 @@ class BaseCommand(object):
usually and they have no built-in callback system.
.. versionchanged:: 2.0
- Added the `context_defaults` parameter.
+ Added the `context_settings` parameter.
:param name: the name of the command to use unless a group overrides it.
- :param context_defaults: an optional dictionary with defaults that are
+ :param context_settings: an optional dictionary with defaults that are
passed to the context object.
"""
- def __init__(self, name, context_defaults=None):
+ def __init__(self, name, context_settings=None):
#: the name the command thinks it has. Upon registering a command
#: on a :class:`Group` the group will default the command name
#: with this information. You should instead use the
#: :class:`Context`\'s :attr:`~Context.info_name` attribute.
self.name = name
#: an optional dictionary with defaults passed to the context.
- self.context_defaults = context_defaults
+ self.context_settings = context_settings
def get_usage(self, ctx):
raise NotImplementedError('Base commands cannot get usage')
@@ -396,7 +396,7 @@ class BaseCommand(object):
:param extra: extra keyword arguments forwarded to the context
constructor.
"""
- for key, value in iteritems(self.context_defaults or {}):
+ for key, value in iteritems(self.context_settings or {}):
if key not in extra:
extra[key] = value
ctx = Context(self, info_name=info_name, parent=parent, **extra)
@@ -494,10 +494,10 @@ class Command(BaseCommand):
more parsing to commands nested below it.
.. versionchanged:: 2.0
- Added the `context_defaults` parameter.
+ Added the `context_settings` parameter.
:param name: the name of the command to use unless a group overrides it.
- :param context_defaults: an optional dictionary with defaults that are
+ :param context_settings: an optional dictionary with defaults that are
passed to the context object.
:param callback: the callback to invoke. This is optional.
:param params: the parameters to register with this command. This can
@@ -512,10 +512,10 @@ class Command(BaseCommand):
"""
allow_extra_args = False
- def __init__(self, name, context_defaults=None, callback=None,
+ 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):
- BaseCommand.__init__(self, name, context_defaults)
+ BaseCommand.__init__(self, name, context_settings)
#: the callback to execute when the command fires. This might be
#: `None` in which case nothing happens.
self.callback = callback
diff --git a/docs/advanced.rst b/docs/advanced.rst
index 9eb87e4..41b8df7 100644
--- a/docs/advanced.rst
+++ b/docs/advanced.rst
@@ -79,9 +79,9 @@ function that converts the token to lowercase. Example:
.. click:example::
- CONTEXT_DEFAULTS = dict(token_normalize_func=lambda x: x.lower())
+ CONTEXT_SETTINGS = dict(token_normalize_func=lambda x: x.lower())
- @click.command(context_defaults=CONTEXT_DEFAULTS)
+ @click.command(context_settings=CONTEXT_SETTINGS)
@click.option('--name', default='Pete')
def cli(name):
click.echo('Name: %s' % name)
diff --git a/docs/commands.rst b/docs/commands.rst
index 620f56f..838c192 100644
--- a/docs/commands.rst
+++ b/docs/commands.rst
@@ -319,11 +319,11 @@ This example does the same as the previous example:
import click
- CONTEXT_DEFAULTS = dict(
+ CONTEXT_SETTINGS = dict(
default_map={'runserver': {'port': 5000}}
)
- @click.group(context_defaults=CONTEXT_DEFAULTS)
+ @click.group(context_settings=CONTEXT_SETTINGS)
def cli():
pass
diff --git a/docs/documentation.rst b/docs/documentation.rst
index fe7d977..65ae11f 100644
--- a/docs/documentation.rst
+++ b/docs/documentation.rst
@@ -148,9 +148,9 @@ instad of just ``--help``:
.. click:example::
- CONTEXT_DEFAULTS = dict(help_option_names=['-h', '--help'])
+ CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])
- @click.command(context_defaults=CONTEXT_DEFAULTS)
+ @click.command(context_settings=CONTEXT_SETTINGS)
def cli():
pass
diff --git a/examples/complex/complex/cli.py b/examples/complex/complex/cli.py
index 6728eef..2f515ab 100644
--- a/examples/complex/complex/cli.py
+++ b/examples/complex/complex/cli.py
@@ -3,7 +3,7 @@ import sys
import click
-CONTEXT_DEFAULTS = dict(auto_envvar_prefix='COMPLEX')
+CONTEXT_SETTINGS = dict(auto_envvar_prefix='COMPLEX')
class Context(object):
@@ -50,7 +50,7 @@ class ComplexCLI(click.MultiCommand):
return mod.cli
-@click.command(cls=ComplexCLI, context_defaults=CONTEXT_DEFAULTS)
+@click.command(cls=ComplexCLI, context_settings=CONTEXT_SETTINGS)
@click.option('--home', type=click.Path(exists=True, file_okay=False,
resolve_path=True),
help='Changes the folder to operate on.')
diff --git a/tests/test_normalization.py b/tests/test_normalization.py
index 91b59bf..5cc4eeb 100644
--- a/tests/test_normalization.py
+++ b/tests/test_normalization.py
@@ -1,11 +1,11 @@
import click
-CONTEXT_DEFAULTS = dict(token_normalize_func=lambda x: x.lower())
+CONTEXT_SETTINGS = dict(token_normalize_func=lambda x: x.lower())
def test_option_normalization(runner):
- @click.command(context_defaults=CONTEXT_DEFAULTS)
+ @click.command(context_settings=CONTEXT_SETTINGS)
@click.option('--foo')
@click.option('-x')
def cli(foo, x):
@@ -17,7 +17,7 @@ def test_option_normalization(runner):
def test_choice_normalization(runner):
- @click.command(context_defaults=CONTEXT_DEFAULTS)
+ @click.command(context_settings=CONTEXT_SETTINGS)
@click.option('--choice', type=click.Choice(['Foo', 'Bar']))
def cli(choice):
click.echo('Foo')
@@ -27,7 +27,7 @@ def test_choice_normalization(runner):
def test_command_normalization(runner):
- @click.group(context_defaults=CONTEXT_DEFAULTS)
+ @click.group(context_settings=CONTEXT_SETTINGS)
def cli():
pass