Skip to content
Myr

Added resilient parsing to the docs

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Armin Ronacher · committed by Armin Ronacher · parent 336e5e0 · Browse files · 1 file+6 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+6 added−2 removed

  • other:+6 added−2 removed

1 file+6 added−2 removed

modified:docs/options.rst+6 added-2 removed
301 unmodified lines
302303.. click:example::304305 def print_version(ctx, param, value):306 if not value:306 if not value or ctx.resilient_parsing:307 return308 click.echo('Version 1.0')309 ctx.exit()310
4 unmodified lines
315 click.echo('Hello World!')316317The `expose_value` parameter prevents the now pretty pointless ``version``318parameter to be passed to the callback. If that was not specified a319boolean would be passed to the `hello` script.319boolean would be passed to the `hello` script. The `resilient_parsing`320flag is set on the context if click wants to parse the command line321without and destructive behavior that would change the execution flow. In322this case because we would exit the program, we instead do nothing in that323case.324325What it looks like:326327.. click:run::
255 unmodified lines