When I run the code below I never see the print output. Take the "click" code out and I do. So, is there a way to prevent "click" from hijacking stdout? Running python 3.10.x on Windows from within PyCharm.
import click
my_cfg = { 'domains': [], 'def_domains': ['stackoverflow.com', 'google.com'] }
@click.command()
@click.option('--domain', '-d', multiple=True, type=str, nargs=1, default=my_cfg['def_domains'])
def domains(domain):
click.echo('\n'.join(domain))
my_cfg['domains'].append(domain)
domains()
print(f"my_cfg: {my_cfg}")
### Bunch of code here that I cannot easily move into domains() ###
Edit1: I'm trying to bolt click into an existing script that I'm adding command line options to. I have a bunch of code that follows domains() that I cannot easily move into domains().
Edit2: I put a breakpoint on the print() in pycharm but it doesn't seem to halt on it. And I never saw an error for using an undefined variable. So maybe click takes over?
cfgvariable. Is this code the same as what you're testing? Also, calling click-decorated functions directly never works right, it's a documented issue.