I have a command as:
import click
@click.command()
@click.option('--count', default=1)
def test(count):
click.echo('Count: %d' % count)
How can I call this test(...)
as normal Python function?
I tried to call the function as test("123")
, but received exception:
Error: Got unexpected extra arguments (1 2 3)
So, assuming that the test(...)
function comes with a third-party package and I can't modify anything in the function, how can I call this test(...)
function?
Click calls this out as an antipattern, and recommends you do things like:
Structuring your code in this way draws a clear separation between your API and your business logic, which is typically useful.