2

My application is callable from the command line and I use Click to parse the options. However, when I run the same main from PyCharm, I have to add the extra options that PyCharm uses when running pydevd.py. This cluters my code with meaningless options and varibles. Example follows:

@click.command()
@click.option('--myOption1')
@click.option('--myOption2')
@click.option('--multiproc',  default=True, is_flag=True) #this option is specific to pydev
@click.option('--qt-support',default=True, is_flag=True) #this option is specific to pydev
@click.option('--client') #this option is specific to pydev
@click.option('--port') #this option is specific to pydev
@click.option('--file') #this option is specific to pydev
def doStuff(myOptions1, myOption2, 
            #the following variables are set by click and have nothing to do with my app
            multiproc, qt_support, client, port, file):
    # myAppCode begins here....  

def main():
    doStuff()

if __name__ == '__main__':
    main()

When PyCharm calls this in the debugger the command is

C:\Anaconda2\python.exe "C:\<aLooongPath>\pydevd.py" --multiproc --qt-support --client 127.0.0.1 --port 44001 --file C:/myModule.py

How can I get it so I can still run the debugger and not have to place the pydevd options as variables into my code?

ThatDataGuy
  • 1,969
  • 2
  • 17
  • 43

1 Answers1

2

See the response to a similar question: Add unspecified options to cli command using python-click.

TL;DR;

@cli.command('foreach', context_settings=dict(ignore_unknown_options=True))
naufraghi
  • 1,514
  • 13
  • 16