I am currently testing a Click CLI application and get result.exit_code == 2. Why does that happen?
I am currently testing a Click CLI application and get result.exit_code == 2. Why does that happen?
This appears to indicate a usage error:
An internal exception that signals a usage error. This typically aborts any further handling.
This is consistent with Click's own tests, e.g.
I ran
result = runner.invoke(cli, ['sync'])
instead of
result = runner.invoke(cli, ['--debug', 'sync'])
So you need to specify the flag as entered via CLI, not only pass the parameters consumed by the function if you use @click.option.
Additionally, the I made a typo for one of the flags.
runner.invoke (simplest: print it)cli(['--debug', 'sync']))In my case this gave me the message
Error: no such option: --sync Did you mean --syncs?