Skip to content

Commit

Permalink
support store_into std::filesystem::path
Browse files Browse the repository at this point in the history
  • Loading branch information
DapengFeng committed Nov 22, 2024
1 parent cbd9fd8 commit ba07769
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions include/argparse/argparse.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ SOFTWARE.
#include <utility>
#include <variant>
#include <vector>
#include <filesystem>
#endif

#ifndef ARGPARSE_CUSTOM_STRTOF
Expand Down Expand Up @@ -730,6 +731,14 @@ class Argument {
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) {
if (m_default_value.has_value()) {
var = std::any_cast<std::vector<std::string>>(m_default_value);
Expand Down

0 comments on commit ba07769

Please sign in to comment.