diff --git a/include/xeus-cpp/xutils.hpp b/include/xeus-cpp/xutils.hpp index a87e3bc7..a80bab8a 100644 --- a/include/xeus-cpp/xutils.hpp +++ b/include/xeus-cpp/xutils.hpp @@ -24,12 +24,6 @@ namespace xcpp XEUS_CPP_API void stop_handler(int sig); - XEUS_CPP_API - bool should_print_version(int argc, char* argv[]); - - XEUS_CPP_API - std::string extract_filename(int &argc, char* argv[]); - XEUS_CPP_API interpreter_ptr build_interpreter(int argc, char** argv); diff --git a/src/main.cpp b/src/main.cpp index 7896b2ec..116b03d1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -22,6 +22,7 @@ #include #include +#include "xeus/xhelper.hpp" #include "xeus-zmq/xzmq_context.hpp" #include @@ -32,7 +33,7 @@ int main(int argc, char* argv[]) { - if (xcpp::should_print_version(argc, argv)) + if (xeus::should_print_version(argc, argv)) { std::clog << "xcpp " << XEUS_CPP_VERSION << std::endl; return 0; @@ -58,7 +59,7 @@ int main(int argc, char* argv[]) #endif signal(SIGINT, xcpp::stop_handler); - std::string file_name = xcpp::extract_filename(argc, argv); + std::string file_name = xeus::extract_filename(argc, argv); interpreter_ptr interpreter = xcpp::build_interpreter(argc, argv); diff --git a/src/xutils.cpp b/src/xutils.cpp index d530f162..c2314480 100644 --- a/src/xutils.cpp +++ b/src/xutils.cpp @@ -50,37 +50,6 @@ namespace xcpp exit(0); } - bool should_print_version(int argc, char* argv[]) - { - for (int i = 0; i < argc; ++i) - { - if (std::string(argv[i]) == "--version") - { - return true; - } - } - return false; - } - - std::string extract_filename(int &argc, char* argv[]) - { - std::string res = ""; - for (int i = 0; i < argc; ++i) - { - if ((std::string(argv[i]) == "-f") && (i + 1 < argc)) - { - res = argv[i + 1]; - for (int j = i; j < argc - 2; ++j) - { - argv[j] = argv[j + 2]; - } - argc -= 2; - break; - } - } - return res; - } - interpreter_ptr build_interpreter(int argc, char** argv) { std::vector interpreter_argv(argc); diff --git a/test/test_interpreter.cpp b/test/test_interpreter.cpp index 364e1fd7..4a5a4688 100644 --- a/test/test_interpreter.cpp +++ b/test/test_interpreter.cpp @@ -260,19 +260,6 @@ TEST_SUITE("is_complete_request") } } -TEST_SUITE("extract_filename") -{ - TEST_CASE("extract_filename_basic_test") - { - const char* arguments[] = {"argument1", "-f", "filename.txt", "argument4"}; - int argc = sizeof(arguments) / sizeof(arguments[0]); - - std::string result = xcpp::extract_filename(argc, const_cast(arguments)); - REQUIRE(result == "filename.txt"); - REQUIRE(argc == 2); - } -} - TEST_SUITE("trim"){ TEST_CASE("trim_basic_test"){ @@ -313,40 +300,6 @@ TEST_SUITE("trim"){ } -TEST_SUITE("should_print_version") -{ - // This test case checks if the function `should_print_version` correctly identifies - // when the "--version" argument is passed. It sets up a scenario where "--version" - // is one of the command line arguments and checks if the function returns true. - TEST_CASE("should_print_version_with_version_arg") - { - char arg1[] = "program_name"; - char arg2[] = "--version"; - char* argv[] = {arg1, arg2}; - int argc = 2; - - bool result = xcpp::should_print_version(argc, argv); - - REQUIRE(result == true); - } - - // This test case checks if the function `should_print_version` correctly identifies - // when the "--version" argument is not passed. It sets up a scenario where "--version" - // is not one of the command line arguments and checks if the function returns false. - TEST_CASE("should_print_version_without_version_arg") - { - char arg1[] = "program_name"; - char arg2[] = "-f"; - char arg3[] = "filename"; - char* argv[] = {arg1, arg2, arg3}; - int argc = 3; - - bool result = xcpp::should_print_version(argc, argv); - - REQUIRE(result == false); - } -} - TEST_SUITE("build_interpreter") { // This test case checks if the function `build_interpreter` returns a non-null pointer