mirror of
https://github.com/CLIUtils/CLI11.git
synced 2025-01-16 07:08:01 +00:00
Compare commits
3 Commits
c439562abb
...
fff3350254
Author | SHA1 | Date | |
---|---|---|---|
|
fff3350254 | ||
|
c426c43b90 | ||
|
747544d7a0 |
@ -6,24 +6,24 @@ FormatStyle: file
|
||||
Checks: '
|
||||
-*,
|
||||
google-*,
|
||||
-google-runtime-int,
|
||||
-google-runtime-references,
|
||||
llvm-include-order,
|
||||
llvm-namespace-comment,
|
||||
misc-throw-by-value-catch-by-reference,
|
||||
modernize*,
|
||||
-modernize-use-trailing-return-type,
|
||||
readability-container-size-empty,
|
||||
'
|
||||
|
||||
WarningsAsErrors: '
|
||||
-*,
|
||||
google-*,
|
||||
-google-runtime-int,
|
||||
-google-runtime-references,
|
||||
llvm-include-order,
|
||||
llvm-namespace-comment,
|
||||
misc-throw-by-value-catch-by-reference,
|
||||
modernize*,
|
||||
-modernize-use-trailing-return-type,
|
||||
readability-container-size-empty,
|
||||
'
|
||||
|
||||
|
@ -62,7 +62,8 @@ jobs:
|
||||
cli11.std: 11
|
||||
Windowslatest:
|
||||
vmImage: 'windows-2019'
|
||||
cli11.std: 17
|
||||
cli11.std: 20
|
||||
cli11.options: -DCMAKE_CXX_FLAG="/std:c++latest"
|
||||
pool:
|
||||
vmImage: $(vmImage)
|
||||
steps:
|
||||
@ -113,6 +114,10 @@ jobs:
|
||||
containerImage: silkeh/clang:8
|
||||
cli11.std: 17
|
||||
cli11.options: -DCLI11_FORCE_LIBCXX=ON
|
||||
clang10_20:
|
||||
containerImage: helics/buildenv:clang10-builder
|
||||
cli11.std: 20
|
||||
cli11.options: -DCLI11_FORCE_LIBCXX=ON -DCMAKE_CXX_FLAGS=-std=c++20
|
||||
container: $[ variables['containerImage'] ]
|
||||
steps:
|
||||
- template: .ci/azure-cmake.yml
|
||||
|
@ -993,7 +993,7 @@ class App {
|
||||
/// creates an option group as part of the given app
|
||||
template <typename T = Option_group>
|
||||
T *add_option_group(std::string group_name, std::string group_description = "") {
|
||||
auto option_group = std::make_shared<T>(std::move(group_description), group_name, nullptr);
|
||||
auto option_group = std::make_shared<T>(std::move(group_description), group_name, this);
|
||||
auto ptr = option_group.get();
|
||||
// move to App_p for overload resolution on older gcc versions
|
||||
App_p app_ptr = std::dynamic_pointer_cast<App>(option_group);
|
||||
@ -3086,7 +3086,18 @@ inline std::string help(const App *app, const Error &e) {
|
||||
namespace detail {
|
||||
/// This class is simply to allow tests access to App's protected functions
|
||||
struct AppFriend {
|
||||
#ifdef CLI11_CPP14
|
||||
|
||||
/// Wrap _parse_short, perfectly forward arguments and return
|
||||
template <typename... Args> static decltype(auto) parse_arg(App *app, Args &&... args) {
|
||||
return app->_parse_arg(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
/// Wrap _parse_subcommand, perfectly forward arguments and return
|
||||
template <typename... Args> static decltype(auto) parse_subcommand(App *app, Args &&... args) {
|
||||
return app->_parse_subcommand(std::forward<Args>(args)...);
|
||||
}
|
||||
#else
|
||||
/// Wrap _parse_short, perfectly forward arguments and return
|
||||
template <typename... Args>
|
||||
static auto parse_arg(App *app, Args &&... args) ->
|
||||
@ -3100,6 +3111,7 @@ struct AppFriend {
|
||||
typename std::result_of<decltype (&App::_parse_subcommand)(App, Args...)>::type {
|
||||
return app->_parse_subcommand(std::forward<Args>(args)...);
|
||||
}
|
||||
#endif
|
||||
/// Wrap the fallthrough parent function to make sure that is working correctly
|
||||
static App *get_fallthrough_parent(App *app) { return app->_get_fallthrough_parent(); }
|
||||
};
|
||||
|
@ -374,6 +374,18 @@ TEST_F(TApp, InvalidOptions) {
|
||||
EXPECT_THROW(ogroup->add_option(opt), CLI::OptionNotFound);
|
||||
}
|
||||
|
||||
TEST_F(TApp, OptionGroupInheritedOptionDefaults) {
|
||||
app.option_defaults()->ignore_case();
|
||||
auto ogroup = app.add_option_group("clusters");
|
||||
int res{0};
|
||||
ogroup->add_option("--test1", res);
|
||||
|
||||
args = {"--Test1", "5"};
|
||||
run();
|
||||
EXPECT_EQ(res, 5);
|
||||
EXPECT_EQ(app.count_all(), 1u);
|
||||
}
|
||||
|
||||
struct ManyGroups : public TApp {
|
||||
|
||||
CLI::Option_group *main{nullptr};
|
||||
|
Loading…
Reference in New Issue
Block a user