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

Dashes in double quoted arg detected as invalid args #239

Open
marekr opened this issue Nov 13, 2022 · 1 comment
Open

Dashes in double quoted arg detected as invalid args #239

marekr opened this issue Nov 13, 2022 · 1 comment

Comments

@marekr
Copy link

marekr commented Nov 13, 2022

Having an string arg

    m_argParser.add_argument( "--user-origin")
            .default_value( std::string() )
            .help( "User-specified output origin ex. 1x1in, 1x1inch, 25.4x25.4mm (default mm)" );

where the cli use is --user-origin="56.100000x27.000000mm" normally works fine.

  1. --user-origin="-56.100000x27.000000mm" where a dash is introduced inside the string, triggers an invalid arg parse error

Changing the double quote to single quote --user-origin='-56.100000x27.000000mm' allows it to work

Examining the argv in msvc, the double quotes do get stripped out by Windows but the arg format of --user-origin= remains

image

while the single quotes remain

image

  1. In the case of the single quote case, argparse then returns everything after the equals sign to the .get() function, including the single quotes which seems kind of odd as well.

I believe in python's argparse.

Doing --user-origin="-21242" is valid form and solution to --user-origin "-21242" not working usually

p-ranav added a commit that referenced this issue Nov 4, 2023
@p-ranav
Copy link
Owner

p-ranav commented Nov 4, 2023

I don't have a Windows computer but does this work if you escape the double quotes?

--user-origin=\"-56.100000x27.000000mm\"

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

2 participants