feat: add point argument handling to parser
Add support for handling Point type arguments in the argument parser. The change includes adding a new point argument and corresponding output handling in main.
This commit is contained in:
@@ -118,7 +118,7 @@ int main() {
|
|||||||
}), false);
|
}), false);
|
||||||
|
|
||||||
parser.add_argument<std::string>("t", "test_store", "Test store", false);
|
parser.add_argument<std::string>("t", "test_store", "Test store", false);
|
||||||
|
parser.add_argument<Point>("p", "point", "Test point", false);
|
||||||
parser.handle_arguments(conventions);
|
parser.handle_arguments(conventions);
|
||||||
|
|
||||||
auto store = parser.get_optional<std::string>("test_store");
|
auto store = parser.get_optional<std::string>("test_store");
|
||||||
@@ -128,5 +128,12 @@ int main() {
|
|||||||
std::cout << "No stored value." << std::endl;
|
std::cout << "No stored value." << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto point = parser.get_optional<Point>("point");
|
||||||
|
if (point.has_value()) {
|
||||||
|
std::cout << "Stored point: " << point.value().x << ", " << point.value().y << std::endl;
|
||||||
|
} else {
|
||||||
|
std::cout << "No stored point." << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user