question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow showing default values globally.

See original GitHub issue

Feature request, as in #646, we already had a discussion how to easily show default values for options. As context_settings is already used to configure global settings anyway, the idea would be to allow the following:

@click.command(
    help='Command helptext',
    context_settings=dict(show_default=True))
@click.option("--test", default="foobar", help="Option helptext")
def cli(test):
    pass

Which should enable show_default for all options and give the following help text:

$ cli --help
Usage: cli [OPTIONS]

  Command helptext

Options:
  --test TEXT   Option helptext. Default: 'foobar'
  --help        Show this message and exit.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:12
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

4reactions
lukeyeagercommented, Aug 29, 2018

Temporary workaround:

import functools
import click

# Use this instead of click.option
click_option = functools.partial(click.option, show_default=True)

@click.command()
@click_option('--name', default='Luke')
def say_hi(name):
    print(name)

if __name__ == '__main__':
    say_hi()
3reactions
ehlescommented, Sep 23, 2019

we have a lot of cli commands and a huge more params for them and going to show default, so we very appreciate for releasing this feature. anyway a year has passed since release 7.0, do you have any plans for releasing 7.1? Thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Use global variables as default values - python - Stack Overflow
Here is a solution with a decorator: from functools import wraps from inspect import getcallargs def defaults_from_globals(f): @wraps(f) def ...
Read more >
Set default values for fields or controls - Microsoft Support
This article explains how to set a default value for a table field or for a control on a form in an Access...
Read more >
Global Picklists - Allow Unique Default Value for Each Field
Global Picklists are great for standardizing picklist options across objects, but don't work if you need to control different default values in individual ......
Read more >
Create default values for your personalization tokens
Enter a default value, which will appear for any visitors who don't have a value for the property you've selected. If you've set...
Read more >
Global - set default values during runtime - NI Community
Hello, Is there a way to reinitialize a global variable to default values during runtime? I know how to do it by passing...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found