dugy / quick_arg_parser Goto Github PK
View Code? Open in Web Editor NEWA single header C++ library for parsing command line arguments and options with minimal amount of code
License: MIT License
A single header C++ library for parsing command line arguments and options with minimal amount of code
License: MIT License
This is a slightly modified version of your short example. The efficiency option is now a std::vector
Here is some output:
% ./a.out -v -e 5
Folder .
Efficiency 5
% ./a.out -v -e 5,6
Folder .
Efficiency 5
Efficiency 6
So far, so good. But what about this?
% ./a.out -v -e 5 -e 6
Folder .
Efficiency 5
This is unfortunate. I think that options that specialize std::vector should allowed to work whether they arguments are in one list or several.
Here is some test code derived from your short example:
test.cpp.zip
Here is its output:
% ./a.out . --efficiency 9 -v
Folder .
Efficiency 9
% ./a.out . -e 9 -v
Folder .
Efficiency 9
These should also work according to the Posix getopt() spec, but they don't.
% ./a.out . -e9 -v
Switch group -e9 contains a switch that needs an argument
% ./a.out . -ve 9
Switch group -ve contains a switch that needs an argument
% ./a.out . -ve9
Switch group -ve9 contains a switch that needs an argument
This should work, but it doesn't:
% ./a.out . --efficiency=9 -v
Unknown switch --efficiency=9
Godbolt: https://godbolt.org/z/74v6n3
example.cpp
<source>(9): error C2668: 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>::basic_string': ambiguous call to overloaded function
C:/data/msvc/14.28.29333/include\xstring(2496): note: could be 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>::basic_string(std::basic_string<char,std::char_traits<char>,std::allocator<char>> &&) noexcept'
C:/data/msvc/14.28.29333/include\xstring(2413): note: or 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>::basic_string(const _Elem *const )'
with
[
_Elem=char
]
C:/data/msvc/14.28.29333/include\xstring(2754): note: or 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>::basic_string(std::initializer_list<_Elem>,const _Alloc &)'
with
[
_Elem=char,
_Alloc=std::allocator<char>
]
<source>(9): note: while trying to match the argument list '(MainArguments<Input>::Grabber<MainArguments<Input>::DummyValidator>)'
Compiler returned: 2
The weird thing is that everything works fine with GCC and Clang.
Hi,
Can you add support for C++ 11?
Thanks and great library.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.