From 8bacffdf90e106f91785ec81ad1ce167d1f429c5 Mon Sep 17 00:00:00 2001 From: geon6 <2493920954@qq.com> Date: Wed, 27 Nov 2024 16:52:29 +0800 Subject: [PATCH] fix bug 385 --- include/argparse/argparse.hpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/include/argparse/argparse.hpp b/include/argparse/argparse.hpp index c8c99b6..5dff11b 100644 --- a/include/argparse/argparse.hpp +++ b/include/argparse/argparse.hpp @@ -697,7 +697,10 @@ class Argument { if (m_default_value.has_value()) { var = std::any_cast(m_default_value); } - action([&var](const auto & /*unused*/) { var = true; }); + action([&var](const auto & /*unused*/) { + var = true; + return var; + }); return *this; } @@ -708,6 +711,7 @@ class Argument { } action([&var](const auto &s) { var = details::parse_number()(s); + return var; }); return *this; } @@ -718,6 +722,7 @@ class Argument { } action([&var](const auto &s) { var = details::parse_number()(s); + return var; }); return *this; } @@ -726,7 +731,10 @@ class Argument { if (m_default_value.has_value()) { var = std::any_cast(m_default_value); } - action([&var](const std::string &s) { var = s; }); + action([&var](const std::string &s) { + var = s; + return var; + }); return *this; } @@ -740,6 +748,7 @@ class Argument { } m_is_used = true; var.push_back(s); + return var; }); return *this; } @@ -754,6 +763,7 @@ class Argument { } m_is_used = true; var.push_back(details::parse_number()(s)); + return var; }); return *this; } @@ -768,6 +778,7 @@ class Argument { } m_is_used = true; var.insert(s); + return var; }); return *this; } @@ -782,6 +793,7 @@ class Argument { } m_is_used = true; var.insert(details::parse_number()(s)); + return var; }); return *this; }