Skip to content

Commit

Permalink
Merge pull request #2247 from joto/contrib-cli11
Browse files Browse the repository at this point in the history
Update included CLI11 library to version 2.4.2
  • Loading branch information
lonvia committed Sep 16, 2024
2 parents fa5b152 + f4eedc5 commit 4e55c79
Show file tree
Hide file tree
Showing 29 changed files with 175 additions and 84 deletions.
2 changes: 1 addition & 1 deletion contrib/CLI11/LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CLI11 2.2 Copyright (c) 2017-2023 University of Cincinnati, developed by Henry
CLI11 2.2 Copyright (c) 2017-2024 University of Cincinnati, developed by Henry
Schreiner under NSF AWARD 1414736. All rights reserved.

Redistribution and use in source and binary forms of CLI11, with or without
Expand Down
2 changes: 1 addition & 1 deletion contrib/CLI11/README.contrib
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Source: https://github.com/CLIUtils/CLI11
Revision: v2.4.1
Revision: v2.4.2
45 changes: 26 additions & 19 deletions contrib/CLI11/README.md

Large diffs are not rendered by default.

15 changes: 11 additions & 4 deletions contrib/CLI11/include/CLI/App.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#pragma once

// IWYU pragma: private, include "CLI/CLI.hpp"

// [CLI11:public_includes:set]
#include <algorithm>
#include <cstdint>
Expand Down Expand Up @@ -733,6 +735,10 @@ class App {
/// Check to see if a subcommand is part of this command (text version)
CLI11_NODISCARD App *get_subcommand(std::string subcom) const;

/// Get a subcommand by name (noexcept non-const version)
/// returns null if subcommand doesn't exist
CLI11_NODISCARD App *get_subcommand_no_throw(std::string subcom) const noexcept;

/// Get a pointer to subcommand by index
CLI11_NODISCARD App *get_subcommand(int index = 0) const;

Expand Down Expand Up @@ -907,8 +913,9 @@ class App {
}

/// Check with name instead of pointer to see if subcommand was selected
CLI11_NODISCARD bool got_subcommand(std::string subcommand_name) const {
return get_subcommand(subcommand_name)->parsed_ > 0;
CLI11_NODISCARD bool got_subcommand(std::string subcommand_name) const noexcept {
App *sub = get_subcommand_no_throw(subcommand_name);
return (sub != nullptr) ? (sub->parsed_ > 0) : false;
}

/// Sets excluded options for the subcommand
Expand Down Expand Up @@ -1038,7 +1045,7 @@ class App {
std::vector<Option *> get_options(const std::function<bool(Option *)> filter = {});

/// Get an option by name (noexcept non-const version)
Option *get_option_no_throw(std::string option_name) noexcept;
CLI11_NODISCARD Option *get_option_no_throw(std::string option_name) noexcept;

/// Get an option by name (noexcept const version)
CLI11_NODISCARD const Option *get_option_no_throw(std::string option_name) const noexcept;
Expand Down Expand Up @@ -1437,5 +1444,5 @@ struct AppFriend {
} // namespace CLI

#ifndef CLI11_COMPILE
#include "impl/App_inl.hpp"
#include "impl/App_inl.hpp" // IWYU pragma: export
#endif
6 changes: 4 additions & 2 deletions contrib/CLI11/include/CLI/Argv.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@

#pragma once

// IWYU pragma: private, include "CLI/CLI.hpp"

// [CLI11:public_includes:set]
#include <string>
#include <vector>
// [CLI11:public_includes:end]

#include <CLI/Macros.hpp>
#include "Macros.hpp"

namespace CLI {
// [CLI11:argv_hpp:verbatim]
Expand All @@ -25,5 +27,5 @@ CLI11_INLINE std::vector<std::string> compute_win32_argv();
} // namespace CLI

#ifndef CLI11_COMPILE
#include "impl/Argv_inl.hpp"
#include "impl/Argv_inl.hpp" // IWYU pragma: export
#endif
4 changes: 4 additions & 0 deletions contrib/CLI11/include/CLI/CLI.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
// CLI Library includes
// Order is important for combiner script

// IWYU pragma: begin_exports

#include "Version.hpp"

#include "Macros.hpp"
Expand Down Expand Up @@ -38,3 +40,5 @@
#include "Config.hpp"

#include "Formatter.hpp"

// IWYU pragma: end_exports
4 changes: 3 additions & 1 deletion contrib/CLI11/include/CLI/Config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#pragma once

// IWYU pragma: private, include "CLI/CLI.hpp"

// [CLI11:public_includes:set]
#include <algorithm>
#include <cctype>
Expand Down Expand Up @@ -49,5 +51,5 @@ void checkParentSegments(std::vector<ConfigItem> &output, const std::string &cur
} // namespace CLI

#ifndef CLI11_COMPILE
#include "impl/Config_inl.hpp"
#include "impl/Config_inl.hpp" // IWYU pragma: export
#endif
2 changes: 2 additions & 0 deletions contrib/CLI11/include/CLI/ConfigFwd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#pragma once

// IWYU pragma: private, include "CLI/CLI.hpp"

// [CLI11:public_includes:set]
#include <algorithm>
#include <fstream>
Expand Down
5 changes: 3 additions & 2 deletions contrib/CLI11/include/CLI/Encoding.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

#pragma once

#include <CLI/Macros.hpp>
// IWYU pragma: private, include "CLI/CLI.hpp"
#include "Macros.hpp"

// [CLI11:public_includes:set]
#include <string>
Expand Down Expand Up @@ -50,5 +51,5 @@ CLI11_INLINE std::filesystem::path to_path(std::string_view str);
} // namespace CLI

#ifndef CLI11_COMPILE
#include "impl/Encoding_inl.hpp"
#include "impl/Encoding_inl.hpp" // IWYU pragma: export
#endif
12 changes: 7 additions & 5 deletions contrib/CLI11/include/CLI/Error.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#pragma once

// IWYU pragma: private, include "CLI/CLI.hpp"

// [CLI11:public_includes:set]
#include <exception>
#include <stdexcept>
Expand Down Expand Up @@ -237,22 +239,22 @@ class RequiredError : public ParseError {
if((min_option == 1) && (max_option == 1) && (used == 0))
return RequiredError("Exactly 1 option from [" + option_list + "]");
if((min_option == 1) && (max_option == 1) && (used > 1)) {
return {"Exactly 1 option from [" + option_list + "] is required and " + std::to_string(used) +
return {"Exactly 1 option from [" + option_list + "] is required but " + std::to_string(used) +
" were given",
ExitCodes::RequiredError};
}
if((min_option == 1) && (used == 0))
return RequiredError("At least 1 option from [" + option_list + "]");
if(used < min_option) {
return {"Requires at least " + std::to_string(min_option) + " options used and only " +
std::to_string(used) + "were given from [" + option_list + "]",
return {"Requires at least " + std::to_string(min_option) + " options used but only " +
std::to_string(used) + " were given from [" + option_list + "]",
ExitCodes::RequiredError};
}
if(max_option == 1)
return {"Requires at most 1 options be given from [" + option_list + "]", ExitCodes::RequiredError};

return {"Requires at most " + std::to_string(max_option) + " options be used and " + std::to_string(used) +
"were given from [" + option_list + "]",
return {"Requires at most " + std::to_string(max_option) + " options be used but " + std::to_string(used) +
" were given from [" + option_list + "]",
ExitCodes::RequiredError};
}
};
Expand Down
4 changes: 3 additions & 1 deletion contrib/CLI11/include/CLI/Formatter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#pragma once

// IWYU pragma: private, include "CLI/CLI.hpp"

// [CLI11:public_includes:set]
#include <algorithm>
#include <string>
Expand All @@ -21,5 +23,5 @@ namespace CLI {
} // namespace CLI

#ifndef CLI11_COMPILE
#include "impl/Formatter_inl.hpp"
#include "impl/Formatter_inl.hpp" // IWYU pragma: export
#endif
2 changes: 2 additions & 0 deletions contrib/CLI11/include/CLI/FormatterFwd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#pragma once

// IWYU pragma: private, include "CLI/CLI.hpp"

// [CLI11:public_includes:set]
#include <functional>
#include <map>
Expand Down
2 changes: 2 additions & 0 deletions contrib/CLI11/include/CLI/Macros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#pragma once

// IWYU pragma: private, include "CLI/CLI.hpp"

// [CLI11:macros_hpp:verbatim]

// The following version macro is very similar to the one in pybind11
Expand Down
4 changes: 3 additions & 1 deletion contrib/CLI11/include/CLI/Option.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#pragma once

// IWYU pragma: private, include "CLI/CLI.hpp"

// [CLI11:public_includes:set]
#include <algorithm>
#include <functional>
Expand Down Expand Up @@ -804,5 +806,5 @@ class Option : public OptionBase<Option> {
} // namespace CLI

#ifndef CLI11_COMPILE
#include "impl/Option_inl.hpp"
#include "impl/Option_inl.hpp" // IWYU pragma: export
#endif
4 changes: 3 additions & 1 deletion contrib/CLI11/include/CLI/Split.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#pragma once

// IWYU pragma: private, include "CLI/CLI.hpp"

// [CLI11:public_includes:set]
#include <string>
#include <tuple>
Expand Down Expand Up @@ -44,5 +46,5 @@ get_names(const std::vector<std::string> &input);
} // namespace CLI

#ifndef CLI11_COMPILE
#include "impl/Split_inl.hpp"
#include "impl/Split_inl.hpp" // IWYU pragma: export
#endif
4 changes: 3 additions & 1 deletion contrib/CLI11/include/CLI/StringTools.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#pragma once

// IWYU pragma: private, include "CLI/CLI.hpp"

// [CLI11:public_includes:set]
#include <algorithm>
#include <iomanip>
Expand Down Expand Up @@ -263,5 +265,5 @@ CLI11_INLINE bool process_quoted_string(std::string &str, char string_char = '\"
} // namespace CLI

#ifndef CLI11_COMPILE
#include "impl/StringTools_inl.hpp"
#include "impl/StringTools_inl.hpp" // IWYU pragma: export
#endif
2 changes: 2 additions & 0 deletions contrib/CLI11/include/CLI/Timer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#pragma once

// IWYU pragma: private, include "CLI/CLI.hpp"

// On GCC < 4.8, the following define is often missing. Due to the
// fact that this library only uses sleep_for, this should be safe
#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 5 && __GNUC_MINOR__ < 8
Expand Down
42 changes: 36 additions & 6 deletions contrib/CLI11/include/CLI/TypeTools.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#pragma once

// IWYU pragma: private, include "CLI/CLI.hpp"

// [CLI11:public_includes:set]
#include <algorithm>
#include <cmath>
Expand Down Expand Up @@ -85,6 +87,23 @@ template <> struct IsMemberType<const char *> {
using type = std::string;
};

namespace adl_detail {
/// Check for existence of user-supplied lexical_cast.
///
/// This struct has to be in a separate namespace so that it doesn't see our lexical_cast overloads in CLI::detail.
/// Standard says it shouldn't see them if it's defined before the corresponding lexical_cast declarations, but this
/// requires a working implementation of two-phase lookup, and not all compilers can boast that (msvc, ahem).
template <typename T, typename S = std::string> class is_lexical_castable {
template <typename TT, typename SS>
static auto test(int) -> decltype(lexical_cast(std::declval<const SS &>(), std::declval<TT &>()), std::true_type());

template <typename, typename> static auto test(...) -> std::false_type;

public:
static constexpr bool value = decltype(test<T, S>(0))::value;
};
} // namespace adl_detail

namespace detail {

// These are utilities for IsMember and other transforming objects
Expand Down Expand Up @@ -166,16 +185,16 @@ template <typename T, typename C> class is_direct_constructible {
#pragma diag_suppress 2361
#endif
#endif
TT{std::declval<CC>()}
TT{std::declval<CC>()}
#ifdef __CUDACC__
#ifdef __NVCC_DIAG_PRAGMA_SUPPORT__
#pragma nv_diag_default 2361
#else
#pragma diag_default 2361
#endif
#endif
,
std::is_move_assignable<TT>());
,
std::is_move_assignable<TT>());

template <typename TT, typename CC> static auto test(int, std::false_type) -> std::false_type;

Expand Down Expand Up @@ -1245,13 +1264,24 @@ bool lexical_cast(const std::string &input, T &output) {

/// Non-string parsable by a stream
template <typename T,
enable_if_t<classify_object<T>::value == object_category::other && !std::is_assignable<T &, int>::value,
enable_if_t<classify_object<T>::value == object_category::other && !std::is_assignable<T &, int>::value &&
is_istreamable<T>::value,
detail::enabler> = detail::dummy>
bool lexical_cast(const std::string &input, T &output) {
static_assert(is_istreamable<T>::value,
return from_stream(input, output);
}

/// Fallback overload that prints a human-readable error for types that we don't recognize and that don't have a
/// user-supplied lexical_cast overload.
template <typename T,
enable_if_t<classify_object<T>::value == object_category::other && !std::is_assignable<T &, int>::value &&
!is_istreamable<T>::value && !adl_detail::is_lexical_castable<T>::value,
detail::enabler> = detail::dummy>
bool lexical_cast(const std::string & /*input*/, T & /*output*/) {
static_assert(!std::is_same<T, T>::value, // Can't just write false here.
"option object type must have a lexical cast overload or streaming input operator(>>) defined, if it "
"is convertible from another type use the add_option<T, XC>(...) with XC being the known type");
return from_stream(input, output);
return false;
}

/// Assign a value through lexical cast operations
Expand Down
4 changes: 3 additions & 1 deletion contrib/CLI11/include/CLI/Validators.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#pragma once

// IWYU pragma: private, include "CLI/CLI.hpp"

#include "Error.hpp"
#include "Macros.hpp"
#include "StringTools.hpp"
Expand Down Expand Up @@ -892,5 +894,5 @@ CLI11_INLINE std::pair<std::string, std::string> split_program_name(std::string
} // namespace CLI

#ifndef CLI11_COMPILE
#include "impl/Validators_inl.hpp"
#include "impl/Validators_inl.hpp" // IWYU pragma: export
#endif
6 changes: 4 additions & 2 deletions contrib/CLI11/include/CLI/Version.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@

#pragma once

// IWYU pragma: private, include "CLI/CLI.hpp"

// [CLI11:version_hpp:verbatim]

#define CLI11_VERSION_MAJOR 2
#define CLI11_VERSION_MINOR 4
#define CLI11_VERSION_PATCH 1
#define CLI11_VERSION "2.4.1"
#define CLI11_VERSION_PATCH 2
#define CLI11_VERSION "2.4.2"

// [CLI11:version_hpp:end]
Loading

0 comments on commit 4e55c79

Please sign in to comment.