I am trying to use click
python package to pass a command line argument to a function. The example from official documentation works as explained. But nowhere in the documentation is it mentioned how to return a value back. None of the functions in the documentation returns a value, so I don't understand how to do this.
Given example at documentation:
import click
@click.command()
@click.option('--count', default=3, help='Number of greetings.')
def hello(count):
"""Simple program that greets NAME for a total of COUNT times."""
for x in range(count):
click.echo('Hello')
if __name__ == '__main__':
hello()
What I want to do:
import click
@click.command()
@click.option('--count', default=3, help='Number of greetings.')
def hello(count):
"""Simple program that greets NAME for a total of COUNT times."""
for x in range(count):
click.echo('Hello')
return "hello hi"
if __name__ == '__main__':
print(hello())
"hello hi" is not returned as output on console. Can someone tell me how to achieve this?