diff --git a/src/clapp/value.cpp b/src/clapp/value.cpp index b97fe64dd2cc5bfa4ba450bb4ed2d026e30caaac..e8deedd0c0a5f1b17597f177abfa208373bfbbec 100644 --- a/src/clapp/value.cpp +++ b/src/clapp/value.cpp @@ -175,14 +175,14 @@ double clapp::value::convert_value<double>(const std::string_view param) { } template <> -clapp::fs::path clapp::value::convert_value<clapp::fs::path>( +std::filesystem::path clapp::value::convert_value<std::filesystem::path>( const std::string_view param) { return {param}; } -void clapp::value::path_exists_t::validate(const clapp::fs::path& path, +void clapp::value::path_exists_t::validate(const std::filesystem::path& path, const std::string& param_name) { - if (!clapp::fs::exists(path)) { + if (!std::filesystem::exists(path)) { std::stringstream string_stream; string_stream << "CLI value '" << path << "' for '" << param_name << "' does not exist."; diff --git a/src/include/clapp/CMakeLists.txt b/src/include/clapp/CMakeLists.txt index 18e27c9948da7fda04e7b41fcf3b34a369bd7d19..387f5243f7d51b806d2b62f903f1b0cac9482c01 100644 --- a/src/include/clapp/CMakeLists.txt +++ b/src/include/clapp/CMakeLists.txt @@ -5,7 +5,6 @@ install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/argument.h" "${CMAKE_CURRENT_SOURCE_DIR}/contract.h" "${CMAKE_CURRENT_SOURCE_DIR}/contract.hpp" "${CMAKE_CURRENT_SOURCE_DIR}/exception.h" - "${CMAKE_CURRENT_SOURCE_DIR}/filesystem.h" "${CMAKE_CURRENT_SOURCE_DIR}/main_parser.h" "${CMAKE_CURRENT_SOURCE_DIR}/option.h" "${CMAKE_CURRENT_SOURCE_DIR}/option.hpp" diff --git a/src/include/clapp/argument.h b/src/include/clapp/argument.h index f0faba96e854abc56870d687bfce689479a3fc98..c5228ab1254ff8bd1d0a911f04f76a60533e8e72 100644 --- a/src/include/clapp/argument.h +++ b/src/include/clapp/argument.h @@ -166,7 +166,7 @@ class basic_variadic_argument_t { using bool_argument_t = basic_argument_t<bool>; using string_argument_t = basic_argument_t<std::string>; -using path_argument_t = basic_argument_t<clapp::fs::path>; +using path_argument_t = basic_argument_t<std::filesystem::path>; using int8_argument_t = basic_argument_t<std::int8_t>; using uint8_argument_t = basic_argument_t<std::uint8_t>; using int16_argument_t = basic_argument_t<std::int16_t>; @@ -188,7 +188,8 @@ using hours_argument_t = basic_argument_t<std::chrono::hours>; using variadic_bool_argument_t = basic_variadic_argument_t<bool>; using variadic_string_argument_t = basic_variadic_argument_t<std::string>; -using variadic_path_argument_t = basic_variadic_argument_t<clapp::fs::path>; +using variadic_path_argument_t = + basic_variadic_argument_t<std::filesystem::path>; using variadic_int8_argument_t = basic_variadic_argument_t<std::int8_t>; using variadic_uint8_argument_t = basic_variadic_argument_t<std::uint8_t>; using variadic_int16_argument_t = basic_variadic_argument_t<std::int16_t>; diff --git a/src/include/clapp/filesystem.h b/src/include/clapp/filesystem.h deleted file mode 100644 index 1415ae24d43acf47983604146f7f93c923b15f1b..0000000000000000000000000000000000000000 --- a/src/include/clapp/filesystem.h +++ /dev/null @@ -1,24 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2020 Martin Wölzer -// -// This code is licensed under the MIT License (MIT). -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. -/////////////////////////////////////////////////////////////////////////////// - -#ifndef CLAPP_FILESYSTEM_H -#define CLAPP_FILESYSTEM_H - -#include <filesystem> -namespace clapp { -namespace fs = std::filesystem; -} // namespace clapp - -#endif diff --git a/src/include/clapp/option.h b/src/include/clapp/option.h index 849fea33429d3f779622b413cab09d97a2d3cdbb..9cef5932b6a7903e76b63d9f0c8574f88b3d935e 100644 --- a/src/include/clapp/option.h +++ b/src/include/clapp/option.h @@ -16,10 +16,10 @@ #ifndef CLAPP_OPTION_H #define CLAPP_OPTION_H -#include <clapp/filesystem.h> #include <clapp/parser.h> #include <clapp/value.h> +#include <filesystem> #include <functional> #include <optional> #include <string> @@ -302,7 +302,7 @@ using help_option_t = basic_help_option_t<EXIT_SUCCESS>; using string_param_option_t = basic_param_option_t<std::string>; -using path_param_option_t = basic_param_option_t<clapp::fs::path>; +using path_param_option_t = basic_param_option_t<std::filesystem::path>; using bool_param_option_t = basic_param_option_t<bool>; using int8_param_option_t = basic_param_option_t<std::int8_t>; @@ -326,7 +326,8 @@ using hours_param_option_t = basic_param_option_t<std::chrono::hours>; using vector_string_param_option_t = basic_vector_param_option_t<std::string>; -using vector_path_param_option_t = basic_vector_param_option_t<clapp::fs::path>; +using vector_path_param_option_t = + basic_vector_param_option_t<std::filesystem::path>; using vector_int8_param_option_t = basic_vector_param_option_t<std::int8_t>; using vector_uint8_param_option_t = basic_vector_param_option_t<std::uint8_t>; diff --git a/src/include/clapp/value.h b/src/include/clapp/value.h index 35dd35d4ddf8ec98d5ee632780a93adceb012f8d..c3d90798590f084bb6e69ef2bb7626f0faff6faa 100644 --- a/src/include/clapp/value.h +++ b/src/include/clapp/value.h @@ -16,8 +16,7 @@ #ifndef CLAPP_VALUE_H #define CLAPP_VALUE_H -#include <clapp/filesystem.h> - +#include <filesystem> #include <functional> #include <numeric> #include <optional> @@ -101,7 +100,8 @@ class path_exists_t { [[nodiscard]] static constexpr std::string_view append_restriction_text() noexcept; - static void validate(const fs::path &path, const std::string ¶m_name); + static void validate(const std::filesystem::path &path, + const std::string ¶m_name); }; inline std::string concat_str(const std::string &lhs, const std::string &rhs); diff --git a/src/include/clapp/value.hpp b/src/include/clapp/value.hpp index cad39aad3b69d179a2503c0164a7be6c79a93ac3..e07f52e41f9f0bda20e2fd7661358d4fd433f8a8 100644 --- a/src/include/clapp/value.hpp +++ b/src/include/clapp/value.hpp @@ -198,7 +198,7 @@ template <> double clapp::value::convert_value<double>(std::string_view param); template <> -clapp::fs::path clapp::value::convert_value<clapp::fs::path>( +std::filesystem::path clapp::value::convert_value<std::filesystem::path>( std::string_view param); std::string clapp::value::concat_str(const std::string& lhs, diff --git a/tests/argument.cpp b/tests/argument.cpp index c5f8bd14970a4d1e07172e643b9fcb4f537184d7..aaa3bd440e2ca91ee48ba7304ab18a2cca07d22f 100644 --- a/tests/argument.cpp +++ b/tests/argument.cpp @@ -194,10 +194,10 @@ class argumentT : public ::testing::Test { inline static constexpr std::uint16_t value_uint16{0xc234}; inline static constexpr std::uint8_t value_uint8{0xc2}; inline static constexpr std::uint8_t value_uint8_additional{0xff}; - inline static const clapp::fs::path value_path{"/this/is/my/path"}; + inline static const std::filesystem::path value_path{"/this/is/my/path"}; inline static constexpr const char* value_path_cstring{ "/this/is/my/cstring/path"}; - inline static const clapp::fs::path value_path_additional{ + inline static const std::filesystem::path value_path_additional{ "/this/is/my/additional/path"}; inline static constexpr bool value_true{true}; inline static constexpr bool value_false{false}; @@ -4379,15 +4379,16 @@ TEST_F(argumentT, pathArgumentConstructStrAndCallArgFunc) { clapp::argument::path_argument_t arg{tp, arg_str, desc_str}; ASSERT_NO_THROW((get_arg_func<argument_test_parser_t::argument_func_t>( tp, arg_str)(value_path_cstring))); - ASSERT_THAT(arg, ArgumentGiven(clapp::fs::path{value_path_cstring})); + ASSERT_THAT(arg, ArgumentGiven(std::filesystem::path{value_path_cstring})); } TEST_F(argumentT, pathArgumentConstructStrWithDefaultValueAndCallArgFunc) { clapp::argument::path_argument_t arg{ tp, arg_str, desc_str, argument_test_parser_t::purpose_t::optional, - clapp::value::default_value_t<clapp::fs::path>{value_path_additional}}; + clapp::value::default_value_t<std::filesystem::path>{ + value_path_additional}}; ASSERT_THAT(arg, ArgumentNotGivenDefaultValue( - clapp::fs::path{value_path_additional})); + std::filesystem::path{value_path_additional})); ASSERT_NO_THROW((get_arg_func<argument_test_parser_t::argument_func_t>( tp, arg_str)(value_path.string()))); ASSERT_THAT(arg, ArgumentGiven(value_path)); @@ -4429,7 +4430,7 @@ TEST_F(argumentT, clapp::argument::variadic_path_argument_t arg{tp, arg_str, desc_str}; ASSERT_THAT(tp, ContainsArgument(arg_str)); ASSERT_THAT(arg, ArgumentNotGiven()); - ASSERT_THAT(arg.value(), testing::Eq(std::vector<clapp::fs::path>{})); + ASSERT_THAT(arg.value(), testing::Eq(std::vector<std::filesystem::path>{})); } TEST_F(argumentT, variadicPathArgumentConstructWithAlreadyRegisteredArgThrows) { @@ -4449,12 +4450,12 @@ TEST_F(argumentT, tp, arg_str, desc_str, argument_test_parser_t::purpose_t::optional}; ASSERT_NO_THROW((get_arg_func<argument_test_parser_t::argument_func_t>( tp, arg_str)(value_path.string()))); - ASSERT_THAT( - arg, VariadicArgumentGiven(std::vector<clapp::fs::path>{value_path})); - ASSERT_NO_THROW((get_arg_func<argument_test_parser_t::argument_func_t>( - tp, arg_str)(clapp::fs::path{value_path}.string()))); ASSERT_THAT(arg, VariadicArgumentGiven( - std::vector<clapp::fs::path>{value_path, value_path})); + std::vector<std::filesystem::path>{value_path})); + ASSERT_NO_THROW((get_arg_func<argument_test_parser_t::argument_func_t>( + tp, arg_str)(std::filesystem::path{value_path}.string()))); + ASSERT_THAT(arg, VariadicArgumentGiven(std::vector<std::filesystem::path>{ + value_path, value_path})); } TEST_F(argumentT, variadicPathArgumentConstructStrWithoutCallArgFunc) { @@ -4465,13 +4466,13 @@ TEST_F(argumentT, variadicPathArgumentConstructStrWithoutCallArgFunc) { TEST_F(argumentT, variadicPathArgumentConstructStrAndCallArgFuncMultipleTimes) { clapp::argument::variadic_path_argument_t arg{tp, arg_cstr, desc_str}; ASSERT_NO_THROW((get_arg_func<argument_test_parser_t::argument_func_t>( - tp, arg_cstr)(clapp::fs::path{value_path}.string()))); - ASSERT_THAT( - arg, VariadicArgumentGiven(std::vector<clapp::fs::path>{value_path})); + tp, arg_cstr)(std::filesystem::path{value_path}.string()))); + ASSERT_THAT(arg, VariadicArgumentGiven( + std::vector<std::filesystem::path>{value_path})); ASSERT_NO_THROW((get_arg_func<argument_test_parser_t::argument_func_t>( tp, arg_cstr)(value_path.string()))); - ASSERT_THAT(arg, VariadicArgumentGiven( - std::vector<clapp::fs::path>{value_path, value_path})); + ASSERT_THAT(arg, VariadicArgumentGiven(std::vector<std::filesystem::path>{ + value_path, value_path})); } TEST_F(argumentT, variadicPathArgumentConstructCStrWithoutCallArgFunc) { diff --git a/tests/option.cpp b/tests/option.cpp index b8b6993ff2ea34f261602879672d47c1b1daa376..ec2e51f1a3bccb3ca493077328ac5ed2bd525eca 100644 --- a/tests/option.cpp +++ b/tests/option.cpp @@ -2179,11 +2179,11 @@ TEST_F( TEST_F(optionT, vectorPathParamOptionConstructLongStringAndShortWithDefaultValueThrows) { - ASSERT_THROW( - (clapp::option::vector_path_param_option_t{ - tp, long_opt_str, short_opt, opt_desc_str, - clapp::value::default_value_t<clapp::fs::path>{value_cstr_path}}), - clapp::option_param_exception_t); + ASSERT_THROW((clapp::option::vector_path_param_option_t{ + tp, long_opt_str, short_opt, opt_desc_str, + clapp::value::default_value_t<std::filesystem::path>{ + value_cstr_path}}), + clapp::option_param_exception_t); } TEST_F(optionT, vectorPathParamOptionConstructShort) { diff --git a/tests/value.cpp b/tests/value.cpp index 18bd9f7e88460a77ff713805989a55f6a92b8783..408545eea0886540bfee788813cde3c1503fcd55 100644 --- a/tests/value.cpp +++ b/tests/value.cpp @@ -10,8 +10,8 @@ TEST(value, convertValueString) { } TEST(value, convertValuePath) { - ASSERT_THAT(clapp::value::convert_value<clapp::fs::path>("/tmp/test"), - testing::Eq(clapp::fs::path{"/tmp/test"})); + ASSERT_THAT(clapp::value::convert_value<std::filesystem::path>("/tmp/test"), + testing::Eq(std::filesystem::path{"/tmp/test"})); } TEST(value, convertValueBool) { @@ -459,9 +459,10 @@ TEST(value, pathExistsT) { clapp::value::path_exists_t path_exists; ASSERT_THAT(path_exists.append_restriction_text(), testing::StrEq("existing path")); - EXPECT_NO_THROW(path_exists.validate(clapp::fs::path{"/tmp"}, "option")); + EXPECT_NO_THROW( + path_exists.validate(std::filesystem::path{"/tmp"}, "option")); ASSERT_THROW(path_exists.validate( - clapp::fs::path{"/tmp/aba/sadf/aksk/annsp"}, "arg"), + std::filesystem::path{"/tmp/aba/sadf/aksk/annsp"}, "arg"), clapp::path_does_not_exist_t); } diff --git a/usage/main.cpp b/usage/main.cpp index cf3a0e61d2f9dbd66a332add273cf08a3aff9b39..2875b4cedad21532e26ce5b8ed7fd986279aba4c 100644 --- a/usage/main.cpp +++ b/usage/main.cpp @@ -1,7 +1,6 @@ #include <clapp/argument.h> #include <clapp/build_info.h> #include <clapp/exception.h> -#include <clapp/filesystem.h> #include <clapp/main_parser.h> #include <clapp/option.h> #include <clapp/parser.h>