conda/menuinst

CWP change to argparse breaks shortcuts to execute module with -m option

Closed this issue · 2 comments

Checklist

  • I added a descriptive title
  • I searched open reports and couldn't find a duplicate

What happened?

I have not been the best about keeping my dev computer up to date, so this presented itself when I went to set up a new computer with our production software. We create shortcuts that execute cwp.py using pythonw providing the command to execute pythonw within the relevent environment with the -m option to run our module. These shortcuts did not work on the new machine. Trying to diagnose the issue I attempted to run the shortcut command manually on the terminal (using python instead of pythonw to get feedback:python [Anaconda install location]\cwp.py [environment prefix] [environment prefix]pythonw -m my.module) and got this error:

usage: cwp.py [-h] [--no-console] prefix [args ...] cwp.py: error: unrecognized arguments: -m my.module

I reported this yesterday in issue #167 but after a nights sleep I had an epiphany and not only do I realize this is a different issue, but I realized the cause. argparse is interpreting the -m as a new argument instead of part of the args argument. Did a little research to try to find a solution, but haven't found one so far.

Conda Info

No response

Conda Config

No response

Conda list

No response

Additional Context

No response

I've come back to report I've found a solution, although it required the use of a feature that isn't in the argparse documentation anymore, although it's not planned to be removed. If you instead set nargs=argparse.REMAINDER it works as intended.

Awesome, do you want to submit a PR with the change or would you rather us handle it?