mirror of
https://github.com/KeqingMoe/argparse.git
synced 2025-07-04 15:14:39 +00:00
Merge pull request #386 from DapengFeng/master
support `store_into` std::filesystem::path
This commit is contained in:
commit
e39aa895ab
@ -57,6 +57,7 @@ SOFTWARE.
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
#include <variant>
|
#include <variant>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <filesystem>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef ARGPARSE_CUSTOM_STRTOF
|
#ifndef ARGPARSE_CUSTOM_STRTOF
|
||||||
@ -738,6 +739,14 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto &store_into(std::filesystem::path &var) {
|
||||||
|
if (m_default_value.has_value()) {
|
||||||
|
var = std::any_cast<std::filesystem::path>(m_default_value);
|
||||||
|
}
|
||||||
|
action([&var](const std::string &s) { var = s; });
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
auto &store_into(std::vector<std::string> &var) {
|
auto &store_into(std::vector<std::string> &var) {
|
||||||
if (m_default_value.has_value()) {
|
if (m_default_value.has_value()) {
|
||||||
var = std::any_cast<std::vector<std::string>>(m_default_value);
|
var = std::any_cast<std::vector<std::string>>(m_default_value);
|
||||||
|
Loading…
Reference in New Issue
Block a user