Skip to content

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

Open
@ValentinGrim

Description

@ValentinGrim

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions