Cpp-Argument-Parser/test.cpp

38 lines
1.1 KiB
C++
Raw Normal View History

2022-07-26 02:57:57 +00:00
#include <iostream>
2024-07-08 20:21:09 +00:00
#include "argparser.h"
2022-07-26 02:57:57 +00:00
2024-07-08 20:21:09 +00:00
int main(int argc, char** argv) {
Arguments::String first('f', "none");
2024-07-14 00:56:16 +00:00
first.alias("first");
2022-07-26 02:57:57 +00:00
2024-07-14 01:09:58 +00:00
Arguments::Int second("second", 0);
2024-07-14 00:56:16 +00:00
second.alias('s');
2022-07-26 02:57:57 +00:00
2024-07-14 01:09:58 +00:00
Arguments::Bool third("third");
2024-07-14 00:56:16 +00:00
third.alias("abc").alias('t');
2022-07-26 02:57:57 +00:00
2024-07-14 01:09:58 +00:00
Arguments::PositionalString name("", true);
Arguments::PositionalInt age(0, false);
if (Arguments::parse(argc, argv) != Arguments::NO_ERROR) {
return 0;
}
std::cout << "Found:" << std::endl;
std::cout << "\tFirst: " << first.found << std::endl;
std::cout << "\tSecond: " << second.found << std::endl;
std::cout << "\tThird: " << third.found << std::endl;
std::cout << "\tName: " << name.found << std::endl;
std::cout << "\tAge: " << age.found << std::endl;
std::cout << std::endl << "Values:" << std::endl;
std::cout << "\tFirst: " << first.value << std::endl;
std::cout << "\tSecond: " << second.value << std::endl;
std::cout << "\tName: " << name.value << std::endl;
std::cout << "\tAge: " << age.value << std::endl;
2022-07-26 02:57:57 +00:00
return 0;
}