i made some changes
parent
96e5343d02
commit
e0d36269bf
|
@ -1,6 +1,6 @@
|
|||
cmake_minimum_required(VERSION 3.20)
|
||||
include(cmake/color.cmake)
|
||||
set(BLT_VERSION 4.0.13)
|
||||
set(BLT_VERSION 4.0.14)
|
||||
|
||||
set(BLT_TARGET BLT)
|
||||
|
||||
|
|
|
@ -150,7 +150,7 @@ namespace blt::argparse
|
|||
}
|
||||
};
|
||||
|
||||
using arg_meta_type_helper_t = arg_data_helper_t<i8, i16, i32, i64, u8, u16, u32, u64, float, double, std::string_view>;
|
||||
using arg_meta_type_helper_t = arg_data_helper_t<bool, i8, i16, i32, i64, u8, u16, u32, u64, float, double, std::string_view>;
|
||||
using arg_data_t = arg_meta_type_helper_t::variant_t;
|
||||
|
||||
template <typename T>
|
||||
|
|
|
@ -311,22 +311,42 @@ namespace blt::argparse
|
|||
<< std::endl;
|
||||
std::exit(1);
|
||||
}
|
||||
if (argc == 0)
|
||||
{
|
||||
|
||||
}
|
||||
else if (argc == 1)
|
||||
{
|
||||
switch (flag->m_action)
|
||||
{
|
||||
case action_t::STORE:
|
||||
if (argc == 0)
|
||||
{
|
||||
std::cerr << "Error: argument '" << arg <<
|
||||
"' action is store but takes in no arguments. This condition is invalid!" << std::endl;
|
||||
std::exit(1);
|
||||
}
|
||||
if (argc == 1)
|
||||
flag->m_dest_func(dest, parsed_args, args.front());
|
||||
else
|
||||
{
|
||||
std::cerr << "Error: argument '" << arg << "' action is store but takes in more than one argument. " <<
|
||||
"This condition is invalid, did you mean to use action_t::APPEND or action_t::EXTEND?" << std::endl;
|
||||
std::exit(1);
|
||||
}
|
||||
break;
|
||||
case action_t::APPEND:
|
||||
case action_t::EXTEND:
|
||||
if (argc == 0)
|
||||
{
|
||||
std::cerr << "Error: argument '" << arg <<
|
||||
"' action is append or extend but takes in no arguments. This condition is invalid!" << std::endl;
|
||||
std::exit(1);
|
||||
}
|
||||
flag->m_dest_vec_func(dest, parsed_args, args);
|
||||
break;
|
||||
case action_t::APPEND_CONST:
|
||||
if (argc != 0)
|
||||
{
|
||||
std::cerr << "Error: argument '" << arg << "' action is append const but takes in arguments. "
|
||||
"This condition is invalid!" << std::endl;
|
||||
std::exit(1);
|
||||
}
|
||||
if (flag->m_const_value)
|
||||
{
|
||||
std::cerr << "Append const chosen as an action but const value not provided for argument '" << arg << '\'' <<
|
||||
|
@ -375,17 +395,34 @@ namespace blt::argparse
|
|||
}
|
||||
break;
|
||||
case action_t::STORE_CONST:
|
||||
if (argc != 0)
|
||||
{
|
||||
std::cerr << "Store const flag called with an argument. This condition doesn't make sense." << std::endl;
|
||||
print_usage();
|
||||
std::exit(1);
|
||||
}
|
||||
if (!flag->m_const_value)
|
||||
{
|
||||
std::cerr << "Store const flag called with no value. This condition doesn't make sense." << std::endl;
|
||||
std::exit(1);
|
||||
}
|
||||
parsed_args.m_data.insert({dest, *flag->m_const_value});
|
||||
case action_t::STORE_TRUE:
|
||||
if (argc != 0)
|
||||
{
|
||||
std::cerr << "Store true flag called with an argument. This condition doesn't make sense." << std::endl;
|
||||
print_usage();
|
||||
std::exit(1);
|
||||
}
|
||||
parsed_args.m_data.insert({dest, true});
|
||||
case action_t::STORE_FALSE:
|
||||
if (argc != 0)
|
||||
{
|
||||
std::cerr << "Store false flag called with an argument. This condition doesn't make sense." << std::endl;
|
||||
print_usage();
|
||||
std::exit(1);
|
||||
}
|
||||
parsed_args.m_data.insert({dest, false});
|
||||
case action_t::COUNT:
|
||||
if (parsed_args.m_data.contains(dest))
|
||||
{
|
||||
|
@ -422,10 +459,6 @@ namespace blt::argparse
|
|||
print_version();
|
||||
break;
|
||||
}
|
||||
flag->m_dest_func(dest, parsed_args, args.front());
|
||||
}
|
||||
else
|
||||
flag->m_dest_vec_func(dest, parsed_args, args);
|
||||
}
|
||||
}, flag->m_nargs);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue