I have this code that works fine:
import click
@click.command(context_settings=dict(help_option_names=['-h', '--help']))
@click.option('--team_name', required=True, help='Team name')
@click.option('--input_file', default='url_file.txt', help='Input file name for applications, URLs')
@click.option('--output_file', default='test_results_file.txt', help='Output file name to store test results')
def main(team_name, input_file, output_file):
# function body
if __name__ == '__main__':
main() # how does this work?
As you see, main is being called with no arguments though it is supposed to receive three. How does this work?
click, and presumably your method call tomain()goes through all of those decorators before actually reaching the function body ofmain(). And each ofclick's decorators adds one parameter in as default, since it wasn't specified in your initial call. So by the time you get down to the actualmain()call, the decorators have provided all the default arguments.