1
0
mirror of https://github.com/CLIUtils/CLI11.git synced 2025-01-16 07:08:01 +00:00

Compare commits

...

3 Commits

Author SHA1 Message Date
Philip Top
fff3350254
fix issue with option defaults not propagating to option groups (#450) 2020-05-21 10:07:33 -04:00
Christoph Bachhuber
c426c43b90
Fix clang tidy (#451)
* Add already passing check

* Remove too modern clang-tidy-9 check
2020-05-21 10:06:52 -04:00
Philip Top
747544d7a0
try clang 10 (#459)
* try clang 10

* use helics-builder clang 10 image

* try new image

* try again

* try different flag addition

* try adding cpp20 to visual studio check

* try with the latest flag enabled for visual studio 2019

* try the correct c++ flag

* remove use of std::result_of

* format files
2020-05-21 10:05:32 -04:00
4 changed files with 33 additions and 4 deletions

View File

@ -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,
'

View File

@ -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

View File

@ -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(); }
};

View File

@ -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};