Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Windows] space in arg value between double quote are splitted like it was different arg #312

Open
ValentinGrim opened this issue Nov 21, 2023 · 1 comment

Comments

@ValentinGrim
Copy link

Hi
I recently updated to argparse to version 3.0 on my program.
I have the following argument in my list (the first argument):

parser.add_argument("-p", "--printer")
          .help("The name of the printer")
          .default_value(std::string{});

Previously, I used to call my program like this:
my.exe -p "My Printer"

Double quotes are necessary because I'm running on Windows, and printer names generally contain spaces.

This used to work perfectly before, but now I'm encountering this error:
Zero positional arguments expected, did you mean -o/--output VAR
(I also have an 'output' argument declared just after this one in the list)

I noticed that argparse is splitting spaces enclosed within double quotes and attempting to interpret them as new arguments, even though they are not intended to be.

FYI, I also tested with single quotes, and I faced the same problem.

Feel free to let me know if you need further clarification or adjustments.

@ValentinGrim
Copy link
Author

EDIT: It might not be related to argparse but rather to PowerShell 7.4.0, which I am using.
When calling my.exe from the standard Windows terminal, I do not encounter this issue.
I am leaving the problem here for reference if someone else is facing the same issue...
Thanks for your work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant