bfgroup / Lyra

A simple to use, composable, command line parser for C++ 11 and beyond
https://bfgroup.github.io/Lyra/
Boost Software License 1.0
483 stars 58 forks source link

Negative numbers not handled consistently #14

Closed dcleland closed 4 years ago

dcleland commented 4 years ago

It was looking at switching to use Lyra from an existing command line handling routine and found that negative values on the command line are not handled consistently.

Using

Lyra\examples\doc_example1.cpp

as a test I found that negative values only work if you use '=', with either the short or long options.

"doc_example -w 32" works but "doc_example -w -32" fails

The following Windows batch file shows the passing and failing cases.

-----------------> Cut Here <----------------------

@echo off
@rem
@rem Test to show inconsistancy in handling of negative numbers
@rem
setlocal enableextensions

call :test -w 32
call :test -w -32
call :test -w=32
call :test -w=-32
call :test --width 32
call :test --width -32
call :test --width=32
call :test --width=-32
goto :EOF

:test
@rem echo Test doc_example1 %*
doc_example1 %* > nul: 2>&1
if errorlevel 1 (
echo *FAIL*: doc_example1 %*
) else (
echo Pass: doc_example1 %*
)

goto :EOF

-----------------> Cut Here <----------------------