-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Description
Sentinel is an implementation detail that is not intentionally exposed. However, it is in the context params during a callback: sentinel_in_callback.py
import click
def _validate(ctx, param, value):
you_sentinel = ctx.params.get("you")
you_too_sentinel = ctx.params.get("you_too")
print(f"you: {you_sentinel}")
print(f"you_too: {you_too_sentinel}")
print(f"param: {param}")
print(f"value: {value}")
return value
@click.group()
def basic():
pass
@basic.command()
@click.argument('you', required=False)
@click.option('--you-too', )
@click.option('--yall', callback=_validate)
@click.pass_context
def hello(ctx, you, you_too, yall):
click.echo('Hello World!')
if __name__ == '__main__':
basic()
# python -m sentinel_in_callback hello
> python -m sentinel_in_callback hello
you: Sentinel.UNSET
you_too: Sentinel.UNSET
param: <Option yall>
value: None
Hello World!
Reactions are currently unavailable