diff --git a/.github/workflows/ci_linux.yml b/.github/workflows/ci_linux.yml index 904b81ec..b5d5cede 100644 --- a/.github/workflows/ci_linux.yml +++ b/.github/workflows/ci_linux.yml @@ -12,7 +12,7 @@ concurrency: env: CMAKE_VERSION: 3.10.3 - SEQAN3_NO_VERSION_CHECK: 1 + SHARG_NO_VERSION_CHECK: 1 TZ: Europe/Berlin defaults: diff --git a/.github/workflows/ci_misc.yml b/.github/workflows/ci_misc.yml index 6bd78e60..0ea91698 100644 --- a/.github/workflows/ci_misc.yml +++ b/.github/workflows/ci_misc.yml @@ -12,7 +12,7 @@ concurrency: cancel-in-progress: true env: - SEQAN3_NO_VERSION_CHECK: 1 + SHARG_NO_VERSION_CHECK: 1 TZ: Europe/Berlin defaults: diff --git a/build_system/sharg-config.cmake b/build_system/sharg-config.cmake index bccec35c..5c5ccfac 100644 --- a/build_system/sharg-config.cmake +++ b/build_system/sharg-config.cmake @@ -2,7 +2,7 @@ # Copyright (c) 2006-2021, Knut Reinert & Freie Universität Berlin # Copyright (c) 2016-2021, Knut Reinert & MPI für molekulare Genetik # This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License -# shipped with this file and also available at: https://github.com/seqan/sharg/blob/master/LICENSE.md +# shipped with this file and also available at: https://github.com/seqan/sharg-parser/blob/master/LICENSE.md # ----------------------------------------------------------------------------------------------------- # # This CMake module will try to find SHARG and its dependencies. You can use diff --git a/include/sharg/all.hpp b/include/sharg/all.hpp index e70ba061..6fec3d03 100644 --- a/include/sharg/all.hpp +++ b/include/sharg/all.hpp @@ -2,7 +2,7 @@ // Copyright (c) 2006-2021, Knut Reinert & Freie Universität Berlin // Copyright (c) 2016-2021, Knut Reinert & MPI für molekulare Genetik // This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License -// shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md +// shipped with this file and also available at: https://github.com/seqan/sharg-parser/blob/master/LICENSE.md // ----------------------------------------------------------------------------------------------------- /*!\file @@ -16,26 +16,26 @@ * * # The Argument Parser Class * - * \copydetails seqan3::argument_parser + * \copydetails sharg::argument_parser * * # Parsing Command Line Arguments * - * \copydetails seqan3::argument_parser::parse + * \copydetails sharg::argument_parser::parse * * # Argument Validation * * The SeqAn 3 Argument Parser offers a validation mechanism for (positional_)options - * via callables. You can pass any functor that fulfils the seqan3::validator + * via callables. You can pass any functor that fulfils the sharg::validator * and takes the value passed to the add_(positional_)option function call as * a parameter. We provide some commonly used functor that might come in handy: * - * - seqan3::regex_validator - * - seqan3::value_list_validator - * - seqan3::arithmetic_range_validator - * - seqan3::input_file_validator - * - seqan3::output_file_validator - * - seqan3::input_directory_validator - * - seqan3::output_directory_validator + * - sharg::regex_validator + * - sharg::value_list_validator + * - sharg::arithmetic_range_validator + * - sharg::input_file_validator + * - sharg::output_file_validator + * - sharg::input_directory_validator + * - sharg::output_directory_validator */ #pragma once diff --git a/include/sharg/argument_parser.hpp b/include/sharg/argument_parser.hpp index 2b2c22fd..a3e8f0a0 100644 --- a/include/sharg/argument_parser.hpp +++ b/include/sharg/argument_parser.hpp @@ -2,12 +2,12 @@ // Copyright (c) 2006-2021, Knut Reinert & Freie Universität Berlin // Copyright (c) 2016-2021, Knut Reinert & MPI für molekulare Genetik // This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License -// shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md +// shipped with this file and also available at: https://github.com/seqan/sharg-parser/blob/master/LICENSE.md // ----------------------------------------------------------------------------------------------------- /*!\file * \author Svenja Mehringer - * \brief Provides seqan3::argument_parser class. + * \brief Provides sharg::argument_parser class. */ #pragma once @@ -31,7 +31,7 @@ #include #include -namespace seqan3 +namespace sharg { /*!\brief The SeqAn command line parser. @@ -39,7 +39,7 @@ namespace seqan3 * * \details * - * The seqan3::argument_parser is a general purpose argument parser that provides + * The sharg::argument_parser is a general purpose argument parser that provides * convenient access to the command line arguments passed to the program. * It automatically generates a help page and can export manual-pages as well * as HTML documentation. @@ -71,7 +71,7 @@ namespace seqan3 * need to provide a predeclared variable and some additional information like * the identifier, description or advanced restrictions. To actually retrieve * the value from the command line and enable every other mechanism you need - * to call the seqan3::argument_parser::parse function in the end. + * to call the sharg::argument_parser::parse function in the end. * * \include test/snippet/argument_parser/argument_parser_1.cpp * @@ -109,13 +109,13 @@ namespace seqan3 * * There are two different kinds of errors: Developer errors and user errors. * - * Developer errors are those that violate the seqan3::argument_parser design - * (e.g. calling the seqan3::argument_parser::parse function twice or specifying + * Developer errors are those that violate the sharg::argument_parser design + * (e.g. calling the sharg::argument_parser::parse function twice or specifying * two different options with the same identifier.) - * In this case, a seqan3::design_error is thrown. + * In this case, a sharg::design_error is thrown. * * The second kind are user errors, due to invalid command line calls. In this - * case a seqan3::argument_parser_error is thrown. + * case a sharg::argument_parser_error is thrown. * * For example: * @@ -124,12 +124,12 @@ namespace seqan3 * [PARSER ERROR] Value cast failed for positional option 2: Argument abc could not be casted to type DOUBLE. * ``` * - * See the seqan3::argument_parser::parse documentation for a detailed list of + * See the sharg::argument_parser::parse documentation for a detailed list of * which exceptions are caught. * * ### Update Notifications * - * SeqAn applications that are using the seqan3::argument_parser can check SeqAn servers for version updates. + * SeqAn applications that are using the sharg::argument_parser can check SeqAn servers for version updates. * The functionality helps getting new versions out to users faster. * It is also used to inform application developers of new versions of the SeqAn library * which means that applications ship with less bugs. @@ -142,7 +142,7 @@ namespace seqan3 * Users of applications that have this feature activated can opt-out, by either: * * * disabling it for a specific application simply by setting the option `--version-check false/0` or - * * disabling it for all applications by setting the `SEQAN3_NO_VERSION_CHECK` environment variable. + * * disabling it for all applications by setting the `SHARG_NO_VERSION_CHECK` environment variable. * * Note that in case there is no `--version-check` option (display available options with `-h/--help)`, * then the developer already disabled the version check functionality. @@ -160,15 +160,15 @@ class argument_parser argument_parser(argument_parser &&) = default; //!< Defaulted. argument_parser & operator=(argument_parser &&) = default; //!< Defaulted. - /*!\brief Initializes an seqan3::argument_parser object from the command line arguments. + /*!\brief Initializes an sharg::argument_parser object from the command line arguments. * * \param[in] app_name The name of the app that is displayed on the help page. * \param[in] argc The number of command line arguments. * \param[in] argv The command line arguments to parse. - * \param[in] version_updates Notify users about version updates (default seqan3::update_notifications::on). + * \param[in] version_updates Notify users about version updates (default sharg::update_notifications::on). * \param[in] subcommands A list of subcommands (see \link subcommand_arg_parse subcommand parsing \endlink). * - * \throws seqan3::design_error if the application name contains illegal characters. + * \throws sharg::design_error if the application name contains illegal characters. * * The application name must only contain alpha-numeric characters, '_' or '-', * i.e. the following regex must evaluate to true: `\"^[a-zA-Z0-9_-]+$\"`. @@ -217,7 +217,7 @@ class argument_parser * \brief Add (positional) options and flags to the parser. * \{ */ - /*!\brief Adds an option to the seqan3::argument_parser. + /*!\brief Adds an option to the sharg::argument_parser. * * \tparam option_type Must have a formatted input function (stream >> value). * If option_type is a container, its value type must have the @@ -225,16 +225,16 @@ class argument_parser * regarded as a container). * See FormattedInputFunction . * \tparam validator_type The type of validator to be applied to the option - * value. Must model seqan3::validator. + * value. Must model sharg::validator. * * \param[in, out] value The variable in which to store the given command line argument. * \param[in] short_id The short identifier for the option (e.g. 'a'). * \param[in] long_id The long identifier for the option (e.g. "age"). * \param[in] desc The description of the option to be shown in the help page. - * \param[in] spec Advanced option specification, see seqan3::option_spec. - * \param[in] option_validator A seqan3::validator that verifies the value after parsing (callable). + * \param[in] spec Advanced option specification, see sharg::option_spec. + * \param[in] option_validator A sharg::validator that verifies the value after parsing (callable). * - * \throws seqan3::design_error + * \throws sharg::design_error */ template > //!\cond @@ -259,13 +259,13 @@ class argument_parser format); } - /*!\brief Adds a flag to the seqan3::argument_parser. + /*!\brief Adds a flag to the sharg::argument_parser. * * \param[in, out] value The variable in which to store the given command line argument. * \param[in] short_id The short identifier for the flag (e.g. 'i'). * \param[in] long_id The long identifier for the flag (e.g. "integer"). * \param[in] desc The description of the flag to be shown in the help page. - * \param[in] spec Advanced flag specification, see seqan3::option_spec. + * \param[in] spec Advanced flag specification, see sharg::option_spec. */ void add_flag(bool & value, char const short_id, @@ -279,7 +279,7 @@ class argument_parser std::visit([=, &value] (auto & f) { f.add_flag(value, short_id, long_id, desc, spec); }, format); } - /*!\brief Adds a positional option to the seqan3::argument_parser. + /*!\brief Adds a positional option to the sharg::argument_parser. * * \tparam option_type Must have a formatted input function (stream >> value). * If option_type is a container, its value type must have the @@ -287,13 +287,13 @@ class argument_parser * regarded as a container). * See FormattedInputFunction . * \tparam validator_type The type of validator to be applied to the option - * value. Must model seqan3::validator. + * value. Must model sharg::validator. * * \param[in, out] value The variable in which to store the given command line argument. * \param[in] desc The description of the positional option to be shown in the help page. - * \param[in] option_validator A seqan3::validator that verifies the value after parsing (callable). + * \param[in] option_validator A sharg::validator that verifies the value after parsing (callable). * - * \throws seqan3::design_error + * \throws sharg::design_error * * \details * @@ -330,18 +330,18 @@ class argument_parser * \attention The function must be called at the very end of all parser * related code and should be enclosed in a try catch block as the argument parser may throw. * - * \throws seqan3::design_error if this function was already called before. + * \throws sharg::design_error if this function was already called before. * - * \throws seqan3::option_declared_multiple_times if an option that is not a list was declared multiple times. - * \throws seqan3::user_input_error if an incorrect argument is given as (positional) option value. - * \throws seqan3::required_option_missing if the user did not provide a required option. - * \throws seqan3::too_many_arguments if the command line call contained more arguments than expected. - * \throws seqan3::too_few_arguments if the command line call contained less arguments than expected. - * \throws seqan3::validation_error if the argument was not excepted by the provided validator. + * \throws sharg::option_declared_multiple_times if an option that is not a list was declared multiple times. + * \throws sharg::user_input_error if an incorrect argument is given as (positional) option value. + * \throws sharg::required_option_missing if the user did not provide a required option. + * \throws sharg::too_many_arguments if the command line call contained more arguments than expected. + * \throws sharg::too_few_arguments if the command line call contained less arguments than expected. + * \throws sharg::validation_error if the argument was not excepted by the provided validator. * * \details * - * When no specific key words are supplied, the seqan3::argument_parser + * When no specific key words are supplied, the sharg::argument_parser * starts to process the command line for specified options, flags and * positional options. * @@ -399,7 +399,7 @@ class argument_parser if (std::holds_alternative(format) && !subcommands.empty() && sub_parser == nullptr) { - throw too_few_arguments{detail::to_string("You either forgot or misspelled the subcommand! Please specify" + throw too_few_arguments{seqan3::detail::to_string("You either forgot or misspelled the subcommand! Please specify" " which sub-program you want to use: one of ", subcommands, ". Use -h/--help for more information.")}; } @@ -432,13 +432,13 @@ class argument_parser * \tparam id_type Either type `char` or a type that a `std::string` is constructible from. * \param[in] id The short (`char`) or long (`std::string`) option identifier to search for. * \returns `true` if option identifier `id` was set on the command line by the user. - * \throws seqan3::design_error if the function is used incorrectly (see details below). + * \throws sharg::design_error if the function is used incorrectly (see details below). * * \details * * You can only ask for option identifiers that were added to the parser beforehand via - * `seqan3::argument_parser::add_option`. - * As in the `seqan3::argument_parser::add_option` call, pass short identifiers as a `char` and long identifiers + * `sharg::argument_parser::add_option`. + * As in the `sharg::argument_parser::add_option` call, pass short identifiers as a `char` and long identifiers * as a `std::string` or a type that a `std::string` is constructible from (e.g. a `const char *`). * * ### Example @@ -447,12 +447,12 @@ class argument_parser * * ### Exceptions * - * This function throws a seqan3::design_error if - * * `seqan3::argument_parser::parse()` was not called before. + * This function throws a sharg::design_error if + * * `sharg::argument_parser::parse()` was not called before. * * a long identifier was passed (e.g. a `std::string`) that only consists of a single character. If you mean to * pass a short identifier, please pass it as a `char` not a `std::string`. * * the option identifier cannot be found in the list of valid option identifiers that were added to the parser - * via `seqan3::argument_parser::add_option()` calls beforehand. + * via `sharg::argument_parser::add_option()` calls beforehand. */ template //!\cond @@ -489,10 +489,10 @@ class argument_parser //!\name Structuring the Help Page //!\{ - /*!\brief Adds an help page section to the seqan3::argument_parser. + /*!\brief Adds an help page section to the sharg::argument_parser. * \param[in] title The title of the section. - * \param[in] spec Whether to always display this section title (seqan3::option_spec::standard), only when showing - * the advanced help page (seqan3::option_spec::advanced) or never (seqan3::option_spec::hidden). + * \param[in] spec Whether to always display this section title (sharg::option_spec::standard), only when showing + * the advanced help page (sharg::option_spec::advanced) or never (sharg::option_spec::hidden). * \details This only affects the help page and other output formats. */ void add_section(std::string const & title, option_spec const spec = option_spec::standard) @@ -500,10 +500,10 @@ class argument_parser std::visit([&] (auto & f) { f.add_section(title, spec); }, format); } - /*!\brief Adds an help page subsection to the seqan3::argument_parser. + /*!\brief Adds an help page subsection to the sharg::argument_parser. * \param[in] title The title of the subsection. - * \param[in] spec Whether to always display this subsection title (seqan3::option_spec::standard), only when showing - * the advanced help page (seqan3::option_spec::advanced) or never (seqan3::option_spec::hidden). + * \param[in] spec Whether to always display this subsection title (sharg::option_spec::standard), only when showing + * the advanced help page (sharg::option_spec::advanced) or never (sharg::option_spec::hidden). * \details This only affects the help page and other output formats. */ void add_subsection(std::string const & title, option_spec const spec = option_spec::standard) @@ -511,11 +511,11 @@ class argument_parser std::visit([&] (auto & f) { f.add_subsection(title, spec); }, format); } - /*!\brief Adds an help page text line to the seqan3::argument_parser. + /*!\brief Adds an help page text line to the sharg::argument_parser. * \param[in] text The text to print. * \param[in] is_paragraph Whether to insert as paragraph or just a line (Default: false). - * \param[in] spec Whether to always display this line (seqan3::option_spec::standard), only when showing - * the advanced help page (seqan3::option_spec::advanced) or never (seqan3::option_spec::hidden). + * \param[in] spec Whether to always display this line (sharg::option_spec::standard), only when showing + * the advanced help page (sharg::option_spec::advanced) or never (sharg::option_spec::hidden). * \details * If the line is not a paragraph (false), only one line break is appended, otherwise two line breaks are appended. * This only affects the help page and other output formats. @@ -525,11 +525,11 @@ class argument_parser std::visit([&] (auto & f) { f.add_line(text, is_paragraph, spec); }, format); } - /*!\brief Adds an help page list item (key-value) to the seqan3::argument_parser. + /*!\brief Adds an help page list item (key-value) to the sharg::argument_parser. * \param[in] key The key of the key-value pair of the list item. * \param[in] desc The value of the key-value pair of the list item. - * \param[in] spec Whether to always display this list item (seqan3::option_spec::standard), only when showing - * the advanced help page (seqan3::option_spec::advanced) or never (seqan3::option_spec::hidden). + * \param[in] spec Whether to always display this list item (sharg::option_spec::standard), only when showing + * the advanced help page (sharg::option_spec::advanced) or never (sharg::option_spec::hidden). * * \details * @@ -551,7 +551,7 @@ class argument_parser } //!\} - /*!\brief Aggregates all parser related meta data (see seqan3::argument_parser_meta_data struct). + /*!\brief Aggregates all parser related meta data (see sharg::argument_parser_meta_data struct). * * \attention You should supply as much information as possible to help users * of the application. @@ -562,7 +562,7 @@ class argument_parser * point that can be easily extended. * * You can access the members directly: - * (see seqan3::argument_parser_meta_data for a list of the info members) + * (see sharg::argument_parser_meta_data for a list of the info members) * * \include test/snippet/argument_parser/argument_parser_3.cpp * @@ -633,7 +633,7 @@ class argument_parser std::vector subcommands{}; /*!\brief The format of the argument parser that decides the behavior when - * calling the seqan3::argument_parser::parse function. + * calling the sharg::argument_parser::parse function. * * \details * @@ -654,16 +654,16 @@ class argument_parser //!\brief The command line arguments. std::vector cmd_arguments{}; - /*!\brief Initializes the seqan3::argument_parser class on construction. + /*!\brief Initializes the sharg::argument_parser class on construction. * * \param[in] argc The number of command line arguments. * \param[in] argv The command line arguments. * - * \throws seqan3::too_few_arguments if option --export-help was specified without a value - * \throws seqan3::too_few_arguments if option --version-check was specified without a value - * \throws seqan3::validation_error if the value passed to option --export-help was invalid. - * \throws seqan3::validation_error if the value passed to option --version-check was invalid. - * \throws seqan3::too_few_arguments if a sub parser was configured at construction but a subcommand is missing. + * \throws sharg::too_few_arguments if option --export-help was specified without a value + * \throws sharg::too_few_arguments if option --version-check was specified without a value + * \throws sharg::validation_error if the value passed to option --export-help was invalid. + * \throws sharg::validation_error if the value passed to option --version-check was invalid. + * \throws sharg::too_few_arguments if a sub parser was configured at construction but a subcommand is missing. * * \details * @@ -673,18 +673,18 @@ class argument_parser * by the user: * * - **no arguments** If no arguments are provided on the commandline, the - * seqan3::detail::format_short_help is set. - * - **-h/\--help** sets the format to seqan3::detail::format_help - * - **-hh/\--advanced-help** sets the format to seqan3::detail::format_help + * sharg::detail::format_short_help is set. + * - **-h/\--help** sets the format to sharg::detail::format_help + * - **-hh/\--advanced-help** sets the format to sharg::detail::format_help * and show_advanced_options to `true`. - * - \--version sets the format to seqan3::detail::format_version. - * - \--export-help html sets the format to seqan3::detail::format_html. - * - \--export-help man sets the format to seqan3::detail::format_man. - * - \--export-help ctd sets the format to seqan3::detail::format_ctd. - * - else the format is that to seqan3::detail::format_parse + * - \--version sets the format to sharg::detail::format_version. + * - \--export-help html sets the format to sharg::detail::format_html. + * - \--export-help man sets the format to sharg::detail::format_man. + * - \--export-help ctd sets the format to sharg::detail::format_ctd. + * - else the format is that to sharg::detail::format_parse * * If `--export-help` is specified with a value other than html/man or ctd - * an seqan3::argument_parser_error is thrown. + * an sharg::argument_parser_error is thrown. */ void init(int argc, char const * const * const argv) { @@ -818,7 +818,7 @@ class argument_parser /*!\brief Verifies that the short and the long identifiers are correctly formatted. * \param[in] short_id The short identifier of the command line option/flag. * \param[in] long_id The long identifier of the command line option/flag. - * \throws seqan3::design_error + * \throws sharg::design_error * \details Specifically, checks that identifiers haven't been used before, * the length of long IDs is either empty or longer than one char, * the characters used in the identifiers are all valid, @@ -826,7 +826,7 @@ class argument_parser */ void verify_identifiers(char const short_id, std::string const & long_id) { - auto constexpr allowed = is_alnum || is_char<'_'> || is_char<'@'>; + auto constexpr allowed = seqan3::is_alnum || seqan3::is_char<'_'> || seqan3::is_char<'@'>; if (id_exists(short_id)) throw design_error("Option Identifier '" + std::string(1, short_id) + "' was already used before."); @@ -834,14 +834,14 @@ class argument_parser throw design_error("Option Identifier '" + long_id + "' was already used before."); if (long_id.length() == 1) throw design_error("Long IDs must be either empty, or longer than one character."); - if (!allowed(short_id) && !is_char<'\0'>(short_id)) + if (!allowed(short_id) && !seqan3::is_char<'\0'>(short_id)) throw design_error("Option identifiers may only contain alphanumeric characters, '_', or '@'."); - if (long_id.size() > 0 && is_char<'-'>(long_id[0])) + if (long_id.size() > 0 && seqan3::is_char<'-'>(long_id[0])) throw design_error("First character of long ID cannot be '-'."); std::for_each(long_id.begin(), long_id.end(), [&allowed] (char c) { - if (!(allowed(c) || is_char<'-'>(c))) + if (!(allowed(c) || seqan3::is_char<'-'>(c))) throw design_error("Long identifiers may only contain alphanumeric characters, '_', '-', or '@'."); }); if (detail::format_parse::is_empty_id(short_id) && detail::format_parse::is_empty_id(long_id)) @@ -849,4 +849,4 @@ class argument_parser } }; -} // namespace seqan3 +} // namespace sharg diff --git a/include/sharg/auxiliary.hpp b/include/sharg/auxiliary.hpp index 3c916ed7..67c99f89 100644 --- a/include/sharg/auxiliary.hpp +++ b/include/sharg/auxiliary.hpp @@ -2,7 +2,7 @@ // Copyright (c) 2006-2021, Knut Reinert & Freie Universität Berlin // Copyright (c) 2016-2021, Knut Reinert & MPI für molekulare Genetik // This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License -// shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md +// shipped with this file and also available at: https://github.com/seqan/sharg-parser/blob/master/LICENSE.md // ----------------------------------------------------------------------------------------------------- /*!\file @@ -22,10 +22,10 @@ #include #include -namespace seqan3::custom +namespace sharg::custom { -/*!\brief A type that can be specialised to provide customisation point implementations for the seqan3::argument_parser +/*!\brief A type that can be specialised to provide customisation point implementations for the sharg::argument_parser * such that third party types may be adapted. * \tparam t The type you wish to specialise for. * \ingroup argument_parser @@ -34,8 +34,8 @@ namespace seqan3::custom * * ### Named Enumerations * - * In order to use a third party type within the seqan3::argument_parser::add_option or - * seqan3::argument_parser::add_positional_option call, you can specialise this struct in the following way: + * In order to use a third party type within the sharg::argument_parser::add_option or + * sharg::argument_parser::add_positional_option call, you can specialise this struct in the following way: * * \include test/snippet/argument_parser/custom_argument_parsing_enumeration.cpp * @@ -65,23 +65,23 @@ struct argument_parsing : argument_parsing {}; //!\endcond -} // seqan3::custom +} // sharg::custom -namespace seqan3::detail::adl_only +namespace sharg::detail::adl_only { //!\brief Poison-pill overload to prevent non-ADL forms of unqualified lookup. template std::unordered_map enumeration_names(t) = delete; -//!\brief seqan3::detail::customisation_point_object (CPO) definition for seqan3::enumeration_names. +//!\brief seqan3::detail::customisation_point_object (CPO) definition for sharg::enumeration_names. //!\ingroup argument_parser //!\remark For a complete overview, take a look at \ref argument_parser template -struct enumeration_names_cpo : public detail::customisation_point_object, 1> +struct enumeration_names_cpo : public seqan3::detail::customisation_point_object, 1> { //!\brief CRTP base class seqan3::detail::customisation_point_object. - using base_t = detail::customisation_point_object, 1>; + using base_t = seqan3::detail::customisation_point_object, 1>; //!\brief Only this class is allowed to import the constructors from #base_t. (CRTP safety idiom) using base_t::base_t; @@ -94,13 +94,13 @@ struct enumeration_names_cpo : public detail::customisation_point_object, std::type_identity>; - /*!\brief CPO overload (check 1 out of 2): explicit customisation via `seqan3::custom::argument_parsing` + /*!\brief CPO overload (check 1 out of 2): explicit customisation via `sharg::custom::argument_parsing` * \tparam option_type The type of the option. (Needed to defer instantiation for incomplete types.) */ template - static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<1>) + static constexpr auto SEQAN3_CPO_OVERLOAD(seqan3::detail::priority_tag<1>) ( - /*return*/ seqan3::custom::argument_parsing::enumeration_names /*;*/ + /*return*/ sharg::custom::argument_parsing::enumeration_names /*;*/ ); /*!\brief CPO overload (check 1 out of 2): argument dependent lookup (ADL), i.e. @@ -113,15 +113,15 @@ struct enumeration_names_cpo : public detail::customisation_point_object{})` will be called. */ template - static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<0>) + static constexpr auto SEQAN3_CPO_OVERLOAD(seqan3::detail::priority_tag<0>) ( /*return*/ enumeration_names(option_or_type_identity{}) /*;*/ ); }; -} // namespace seqan3::detail::adl_only +} // namespace sharg::detail::adl_only -namespace seqan3 +namespace sharg { /*!\name Customisation Points @@ -139,7 +139,7 @@ namespace seqan3 * * It acts as a wrapper and looks for two possible implementations (in this order): * - * 1. A static member `enumeration_names` in `seqan3::custom::argument_parsing` that is of type + * 1. A static member `enumeration_names` in `sharg::custom::argument_parsing` that is of type * `std::unordered_map>`. * 2. A free function `enumeration_names(your_type const a)` in the namespace of your type (or as `friend`) which * returns a `std::unordered_map>`. @@ -151,7 +151,7 @@ namespace seqan3 * \include test/snippet/argument_parser/custom_enumeration.cpp * * **Only if you cannot access the namespace of your type to customize** you may specialize - * the seqan3::custom::argument_parsing struct like this: + * the sharg::custom::argument_parsing struct like this: * * \include test/snippet/argument_parser/custom_argument_parsing_enumeration.cpp * @@ -169,27 +169,25 @@ template inline auto const enumeration_names = detail::adl_only::enumeration_names_cpo{}(); //!\} -/*!\interface seqan3::named_enumeration <> - * \brief Checks whether the free function seqan3::enumeration_names can be called on the type. +/*!\concept sharg::named_enumeration + * \brief Checks whether the free function sharg::enumeration_names can be called on the type. * \ingroup argument_parser * \tparam option_type The type to check. * * ### Requirements * - * * A instance of seqan3::enumeration_names must exist and be of type + * * A instance of sharg::enumeration_names must exist and be of type * `std::unordered_map`. * * \remark For a complete overview, take a look at \ref argument_parser */ -//!\cond template concept named_enumeration = requires { - { seqan3::enumeration_names }; + { sharg::enumeration_names }; }; -//!\endcond -/*!\interface seqan3::argument_parser_compatible_option <> +/*!\concept sharg::argument_parser_compatible_option * \brief Checks whether the the type can be used in an add_(positional_)option call on the argument parser. * \ingroup argument_parser * \tparam option_type The type to check. @@ -197,45 +195,15 @@ concept named_enumeration = requires * ### Requirements * * In order to model this concept, the type must either be streamable to std::istringstream or - * model seqan3::named_enumeration. + * model sharg::named_enumeration. * * \remark For a complete overview, take a look at \ref argument_parser */ -//!\cond template -concept argument_parser_compatible_option = input_stream_over || +concept argument_parser_compatible_option = seqan3::input_stream_over || named_enumeration; -//!\endcond -/*!\name Formatted output overloads - * \{ - */ -/*!\brief A type (e.g. an enum) can be made debug streamable by customizing the seqan3::enumeration_names. - * \tparam option_type Type of the enum to be printed. - * \param s The seqan3::debug_stream. - * \param op The value to print. - * \relates seqan3::debug_stream_type - * - * \details - * - * This searches the seqan3::enumeration_names of the respective type for the value \p op and prints the - * respective string if found or '\' if the value cannot be found in the map. - */ -template -//!\cond - requires named_enumeration> -//!\endcond -inline debug_stream_type & operator<<(debug_stream_type & s, option_type && op) -{ - for (auto & [key, value] : enumeration_names) - { - if (op == value) - return s << key; - } - return s << ""; -} -//!\} /*!\brief Used to further specify argument_parser options/flags. * \ingroup argument_parser @@ -267,14 +235,14 @@ enum option_spec */ }; -//!\brief Indicates whether application allows automatic update notifications by the seqan3::argument_parser. +//!\brief Indicates whether application allows automatic update notifications by the sharg::argument_parser. enum class update_notifications { on, //!< Automatic update notifications should be enabled. off //!< Automatic update notifications should be disabled. }; -/*!\brief Stores all parser related meta information of the seqan3::argument_parser. +/*!\brief Stores all parser related meta information of the sharg::argument_parser. * \ingroup argument_parser * * \attention You should supply as much information as possible to help the users @@ -340,4 +308,22 @@ struct argument_parser_meta_data // holds all meta information std::vector examples; }; -} // namespace seqan3 +} // namespace sharg + +//!\cond +namespace seqan3 +{ +template + requires sharg::named_enumeration> +inline debug_stream_type & operator<<(debug_stream_type & s, option_type && op) +{ + for (auto & [key, value] : sharg::enumeration_names) + { + if (op == value) + return s << key; + } + + return s << ""; +} +} +//!\endcond diff --git a/include/sharg/detail/concept.hpp b/include/sharg/detail/concept.hpp index cecb5da7..5e760118 100644 --- a/include/sharg/detail/concept.hpp +++ b/include/sharg/detail/concept.hpp @@ -2,12 +2,12 @@ // Copyright (c) 2006-2021, Knut Reinert & Freie Universität Berlin // Copyright (c) 2016-2021, Knut Reinert & MPI für molekulare Genetik // This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License -// shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md +// shipped with this file and also available at: https://github.com/seqan/sharg-parser/blob/master/LICENSE.md // ----------------------------------------------------------------------------------------------------- /*!\file * \author Svenja Mehringer - * \brief Provides the concept seqan3::detail::is_container_option. + * \brief Provides the concept sharg::detail::is_container_option. */ #pragma once @@ -18,10 +18,10 @@ #include -namespace seqan3::detail +namespace sharg::detail { -/*!\interface seqan3::detail::is_container_option <> +/*!\concept sharg::detail::is_container_option * \ingroup argument_parser * \brief Whether the option type is considered to be a container. * \details @@ -38,7 +38,6 @@ namespace seqan3::detail * * \noapi */ -//!\cond template concept is_container_option = !std::is_same_v, std::string> && requires (option_type container, @@ -46,6 +45,5 @@ concept is_container_option = !std::is_same_v, { { container.push_back(value) }; }; -//!\endcond -} // namespace seqan3::detail +} // namespace sharg::detail diff --git a/include/sharg/detail/format_base.hpp b/include/sharg/detail/format_base.hpp index f7fc3cdf..dc6e3fee 100644 --- a/include/sharg/detail/format_base.hpp +++ b/include/sharg/detail/format_base.hpp @@ -2,7 +2,7 @@ // Copyright (c) 2006-2021, Knut Reinert & Freie Universität Berlin // Copyright (c) 2016-2021, Knut Reinert & MPI für molekulare Genetik // This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License -// shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md +// shipped with this file and also available at: https://github.com/seqan/sharg-parser/blob/master/LICENSE.md // ----------------------------------------------------------------------------------------------------- /*!\file @@ -26,7 +26,7 @@ #include #include -namespace seqan3::detail +namespace sharg::detail { /*!\brief The format that contains all helper functions needed in all formats. @@ -44,20 +44,20 @@ class format_base static std::string get_type_name_as_string(value_type const & /**/) { using type = std::decay_t; - using types = type_list; + using types = seqan3::type_list; std::vector names{"signed 8 bit integer", "unsigned 8 bit integer", "signed 16 bit integer", @@ -73,10 +73,10 @@ class format_base "std::string", "std::filesystem::path"}; - if constexpr (list_traits::contains) - return names[list_traits::find]; + if constexpr (seqan3::list_traits::contains) + return names[seqan3::list_traits::find]; else - return detail::type_name_as_string; + return seqan3::detail::type_name_as_string; } /*!\brief Returns the `value_type` of the input container as a string (reflection). @@ -102,7 +102,7 @@ class format_base } /*!\brief Formats the container and its value_type for the help page printing. - * \tparam container_type A type that must satisfy the seqan3::detail::is_container_option. + * \tparam container_type A type that must satisfy the sharg::detail::is_container_option. * \param[in] container The container to deduct the type from. * * \returns The type of the container value type as a string, encapsulated in "List of". @@ -219,8 +219,8 @@ class format_help_base : public format_base //!\} public: - /*!\brief Adds a seqan3::print_list_item call to be evaluated later on. - * \copydetails seqan3::argument_parser::add_option + /*!\brief Adds a sharg::print_list_item call to be evaluated later on. + * \copydetails sharg::argument_parser::add_option */ template void add_option(option_type & value, @@ -232,15 +232,15 @@ class format_help_base : public format_base { std::string id = prep_id_for_help(short_id, long_id) + " " + option_type_and_list_info(value); std::string info{desc}; - info += ((spec & option_spec::required) ? std::string{" "} : detail::to_string(" Default: ", value, ". ")); + info += ((spec & option_spec::required) ? std::string{" "} : seqan3::detail::to_string(" Default: ", value, ". ")); info += option_validator.get_help_page_message(); store_help_page_element([this, id, info] () { derived_t().print_list_item(id, info); }, spec); } - /*!\brief Adds a seqan3::print_list_item call to be evaluated later on. - * \copydetails seqan3::argument_parser::add_flag + /*!\brief Adds a sharg::print_list_item call to be evaluated later on. + * \copydetails sharg::argument_parser::add_flag */ - void add_flag(bool & SEQAN3_DOXYGEN_ONLY(value), + void add_flag(bool & SHARG_DOXYGEN_ONLY(value), char const short_id, std::string const & long_id, std::string const & desc, @@ -250,8 +250,8 @@ class format_help_base : public format_base store_help_page_element([this, id, desc] () { derived_t().print_list_item(id, desc); }, spec); } - /*!\brief Adds a seqan3::print_list_item call to be evaluated later on. - * \copydetails seqan3::argument_parser::add_positional_option + /*!\brief Adds a sharg::print_list_item call to be evaluated later on. + * \copydetails sharg::argument_parser::add_positional_option */ template void add_positional_option(option_type & value, @@ -263,12 +263,12 @@ class format_help_base : public format_base positional_option_calls.push_back([this, &value, desc, msg] () { ++positional_option_count; - derived_t().print_list_item(detail::to_string("\\fBARGUMENT-", positional_option_count, "\\fP ", + derived_t().print_list_item(seqan3::detail::to_string("\\fBARGUMENT-", positional_option_count, "\\fP ", option_type_and_list_info(value)), desc + // a list at the end may be empty and thus have a default value ((detail::is_container_option) - ? detail::to_string(" Default: ", value, ". ") + ? seqan3::detail::to_string(" Default: ", value, ". ") : std::string{" "}) + msg); }); @@ -342,7 +342,7 @@ class format_help_base : public format_base } /*!\brief Adds a print_section call to parser_set_up_calls. - * \copydetails seqan3::argument_parser::add_section + * \copydetails sharg::argument_parser::add_section */ void add_section(std::string const & title, option_spec const spec) { @@ -350,7 +350,7 @@ class format_help_base : public format_base } /*!\brief Adds a print_subsection call to parser_set_up_calls. - * \copydetails seqan3::argument_parser::add_subsection + * \copydetails sharg::argument_parser::add_subsection */ void add_subsection(std::string const & title, option_spec const spec) { @@ -358,15 +358,15 @@ class format_help_base : public format_base } /*!\brief Adds a print_line call to parser_set_up_calls. - * \copydetails seqan3::argument_parser::add_line + * \copydetails sharg::argument_parser::add_line */ void add_line(std::string const & text, bool is_paragraph, option_spec const spec) { store_help_page_element([this, text, is_paragraph] () { derived_t().print_line(text, is_paragraph); }, spec); } - /*!\brief Adds a seqan3::print_list_item call to parser_set_up_calls. - * \copydetails seqan3::argument_parser::add_list_item + /*!\brief Adds a sharg::print_list_item call to parser_set_up_calls. + * \copydetails sharg::argument_parser::add_list_item */ void add_list_item(std::string const & key, std::string const & desc, option_spec const spec) { @@ -412,7 +412,7 @@ class format_help_base : public format_base } } - /*!\brief Delegates to seqan3::print_line(std::string const & text, true) of each format. + /*!\brief Delegates to sharg::print_line(std::string const & text, true) of each format. * \param[in] text The text to print. */ void print_line(std::string const & text) @@ -423,7 +423,7 @@ class format_help_base : public format_base //!\brief Prints the version information. void print_version() { - std::string const version_str{seqan3_version_cstring}; + std::string const version_str{sharg::sharg_version_cstring}; // Print version, date and url. derived_t().print_section("Version"); @@ -502,8 +502,8 @@ class format_help_base : public format_base * * \details * - * If `spec` equals `seqan3::option_spec::hidden`, the information is never added to the help page. - * If `spec` equals `seqan3::option_spec::advanced`, the information is only added to the help page if + * If `spec` equals `sharg::option_spec::hidden`, the information is never added to the help page. + * If `spec` equals `sharg::option_spec::advanced`, the information is only added to the help page if * the advanced help page has been queried on the command line (`show_advanced_options == true`). */ void store_help_page_element(std::function printer, option_spec const spec) @@ -513,4 +513,4 @@ class format_help_base : public format_base } }; -} // namespace seqan3::detail +} // namespace sharg::detail diff --git a/include/sharg/detail/format_help.hpp b/include/sharg/detail/format_help.hpp index 7d9e5e30..a54b0762 100644 --- a/include/sharg/detail/format_help.hpp +++ b/include/sharg/detail/format_help.hpp @@ -2,7 +2,7 @@ // Copyright (c) 2006-2021, Knut Reinert & Freie Universität Berlin // Copyright (c) 2016-2021, Knut Reinert & MPI für molekulare Genetik // This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License -// shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md +// shipped with this file and also available at: https://github.com/seqan/sharg-parser/blob/master/LICENSE.md // ----------------------------------------------------------------------------------------------------- /*!\file @@ -21,7 +21,7 @@ #include #include -namespace seqan3::detail +namespace sharg::detail { /*!\brief The format that prints the help page to std::cout. @@ -391,7 +391,7 @@ class format_help : public format_help_base * * The short help message printing is not done immediately, because the user cannot provide * meta information (e.g. app_name) on construction of the parser. Thus the meta information is collected - * and only evaluated when calling seqan3::detail::format_version::parse. + * and only evaluated when calling sharg::detail::format_version::parse. * * \remark For a complete overview, take a look at \ref argument_parser */ @@ -451,7 +451,7 @@ class format_version : public format_help * * The copyright message printing is not done immediately, because the user cannot provide * meta information (e.g. long_copyright) on construction of the parser. Thus the meta information is collected - * and only evaluated when calling seqan3::detail::format_version::parse. + * and only evaluated when calling sharg::detail::format_version::parse. * * \remark For a complete overview, take a look at \ref argument_parser */ @@ -464,7 +464,7 @@ class format_copyright : public format_help void parse(argument_parser_meta_data const & parser_meta) { meta = parser_meta; - debug_stream_type stream{std::cout}; + seqan3::debug_stream_type stream{std::cout}; std::string seqan_license{ R"(Copyright (c) 2006-2021, Knut Reinert & Freie Universität Berlin Copyright (c) 2016-2021, Knut Reinert & MPI für molekulare Genetik @@ -521,4 +521,4 @@ DAMAGE.)"}; } }; -} // namespace seqan3::detail +} // namespace sharg::detail diff --git a/include/sharg/detail/format_html.hpp b/include/sharg/detail/format_html.hpp index 81dc8e69..5b4022c6 100644 --- a/include/sharg/detail/format_html.hpp +++ b/include/sharg/detail/format_html.hpp @@ -2,7 +2,7 @@ // Copyright (c) 2006-2021, Knut Reinert & Freie Universität Berlin // Copyright (c) 2016-2021, Knut Reinert & MPI für molekulare Genetik // This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License -// shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md +// shipped with this file and also available at: https://github.com/seqan/sharg-parser/blob/master/LICENSE.md // ----------------------------------------------------------------------------------------------------- /*!\file @@ -18,7 +18,7 @@ #include #include -namespace seqan3::detail +namespace sharg::detail { /*!\brief The format that prints the help page as html to std::cout. @@ -250,4 +250,4 @@ class format_html : public format_help_base bool is_p{false}; }; -} // namespace seqan3 +} // namespace sharg diff --git a/include/sharg/detail/format_man.hpp b/include/sharg/detail/format_man.hpp index 7d26d32a..c256c410 100644 --- a/include/sharg/detail/format_man.hpp +++ b/include/sharg/detail/format_man.hpp @@ -2,7 +2,7 @@ // Copyright (c) 2006-2021, Knut Reinert & Freie Universität Berlin // Copyright (c) 2016-2021, Knut Reinert & MPI für molekulare Genetik // This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License -// shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md +// shipped with this file and also available at: https://github.com/seqan/sharg-parser/blob/master/LICENSE.md // ----------------------------------------------------------------------------------------------------- /*!\file @@ -18,7 +18,7 @@ #include #include -namespace seqan3::detail +namespace sharg::detail { /*!\brief The format that prints the help page information formatted for a man page to std::cout. @@ -30,7 +30,7 @@ namespace seqan3::detail * provide meta information, positional options, etc. in the correct order. * In addition the needed order would be different from the parse format. * Thus the calls are stored (parser_set_up_calls and positional_option_calls) - * and only evaluated when calling seqan3::detail::format_help_base::parse. + * and only evaluated when calling sharg::detail::format_help_base::parse. * * \remark For a complete overview, take a look at \ref argument_parser */ @@ -150,4 +150,4 @@ class format_man : public format_help_base bool is_first_in_section{true}; }; -} // namespace seqan3 +} // namespace sharg diff --git a/include/sharg/detail/format_parse.hpp b/include/sharg/detail/format_parse.hpp index d863702a..09b0acd3 100644 --- a/include/sharg/detail/format_parse.hpp +++ b/include/sharg/detail/format_parse.hpp @@ -2,7 +2,7 @@ // Copyright (c) 2006-2021, Knut Reinert & Freie Universität Berlin // Copyright (c) 2016-2021, Knut Reinert & MPI für molekulare Genetik // This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License -// shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md +// shipped with this file and also available at: https://github.com/seqan/sharg-parser/blob/master/LICENSE.md // ----------------------------------------------------------------------------------------------------- /*!\file @@ -21,7 +21,7 @@ #include #include -namespace seqan3::detail +namespace sharg::detail { /*!\brief The format that organizes the actual parsing of command line arguments. @@ -34,7 +34,7 @@ namespace seqan3::detail * Directly parsing is also difficult, since the order of parsing options/flags * is non trivial (e.g. ambiguousness of '-g 4' => option+value or flag+positional). * Therefore, we store the parsing calls of the developer in a function object, - * (format_parse::option_and_flag_calls, seqan3::detail::format_parse::positional_option_calls) + * (format_parse::option_and_flag_calls, sharg::detail::format_parse::positional_option_calls) * executing them in a new order when calling format_parse::parse(). * This enables us to parse any option type and resolve any ambiguousness, so no * additional restrictions apply to the developer when setting up the parser. @@ -72,14 +72,14 @@ class format_parse : public format_base {} //!\} - /*!\brief Adds an seqan3::detail::get_option call to be evaluated later on. - * \copydetails seqan3::argument_parser::add_option + /*!\brief Adds an sharg::detail::get_option call to be evaluated later on. + * \copydetails sharg::argument_parser::add_option */ template void add_option(option_type & value, char const short_id, std::string const & long_id, - std::string const & SEQAN3_DOXYGEN_ONLY(desc), + std::string const & SHARG_DOXYGEN_ONLY(desc), option_spec const spec, validator_type && option_validator) { @@ -90,13 +90,13 @@ class format_parse : public format_base } /*!\brief Adds a get_flag call to be evaluated later on. - * \copydetails seqan3::argument_parser::add_flag + * \copydetails sharg::argument_parser::add_flag */ void add_flag(bool & value, char const short_id, std::string const & long_id, - std::string const & SEQAN3_DOXYGEN_ONLY(desc), - option_spec const & SEQAN3_DOXYGEN_ONLY(spec)) + std::string const & SHARG_DOXYGEN_ONLY(desc), + option_spec const & SHARG_DOXYGEN_ONLY(spec)) { flag_calls.push_back([this, &value, short_id, long_id]() { @@ -105,11 +105,11 @@ class format_parse : public format_base } /*!\brief Adds a get_positional_option call to be evaluated later on. - * \copydetails seqan3::argument_parser::add_positional_option + * \copydetails sharg::argument_parser::add_positional_option */ template void add_positional_option(option_type & value, - std::string const & SEQAN3_DOXYGEN_ONLY(desc), + std::string const & SHARG_DOXYGEN_ONLY(desc), validator_type && option_validator) { positional_option_calls.push_back([this, &value, option_validator]() @@ -157,7 +157,7 @@ class format_parse : public format_base if constexpr (std::same_as, std::string>) return id.empty(); else // char - return is_char<'\0'>(id); + return seqan3::is_char<'\0'>(id); } /*!\brief Finds the position of a short/long identifier in format_parse::argv. @@ -289,15 +289,15 @@ class format_parse : public format_base } /*!\brief Tries to parse an input string into a value using the stream `operator>>`. - * \tparam option_t Must model seqan3::input_stream_over. + * \tparam option_t Must model sharg::seqan3::input_stream_over. * \param[out] value Stores the parsed value. * \param[in] in The input argument to be parsed. - * \returns seqan3::option_parse_result::error if `in` could not be parsed via the stream - * operator and otherwise seqan3::option_parse_result::success. + * \returns sharg::option_parse_result::error if `in` could not be parsed via the stream + * operator and otherwise sharg::option_parse_result::success. */ template //!\cond - requires input_stream_over + requires seqan3::input_stream_over //!\endcond option_parse_result parse_option_value(option_t & value, std::string const & in) { @@ -310,17 +310,17 @@ class format_parse : public format_base return option_parse_result::success; } - /*!\brief Sets an option value depending on the keys found in seqan3::enumeration_names. - * \tparam option_t Must model seqan3::named_enumeration. + /*!\brief Sets an option value depending on the keys found in sharg::enumeration_names. + * \tparam option_t Must model sharg::named_enumeration. * \param[out] value Stores the parsed value. * \param[in] in The input argument to be parsed. - * \throws seqan3::user_input_error if `in` is not a key in seqan3::enumeration_names. - * \returns seqan3::option_parse_result::success. + * \throws sharg::user_input_error if `in` is not a key in sharg::enumeration_names. + * \returns sharg::option_parse_result::success. */ template option_parse_result parse_option_value(option_t & value, std::string const & in) { - auto map = seqan3::enumeration_names; + auto map = sharg::enumeration_names; if (auto it = map.find(in); it == map.end()) { @@ -335,7 +335,7 @@ class format_parse : public format_base return pair1.first < pair2.first; }); - throw user_input_error{detail::to_string("You have chosen an invalid input value: ", in, + throw user_input_error{seqan3::detail::to_string("You have chosen an invalid input value: ", in, ". Please use one of: ", key_value_pairs | std::views::keys)}; } else @@ -355,7 +355,7 @@ class format_parse : public format_base //!\endcond /*!\brief Parses the given option value and appends it to the target container. - * \tparam container_option_t Must model seqan3::detail::is_container_option and + * \tparam container_option_t Must model sharg::detail::is_container_option and * its value_type must be parseable via parse_option_value * \tparam format_parse_t Needed to make the function "dependent" (i.e. do instantiation in the second phase of * two-phase lookup) as the requires clause needs to be able to access the other @@ -363,7 +363,7 @@ class format_parse : public format_base * * \param[out] value The container that stores the parsed value. * \param[in] in The input argument to be parsed. - * \returns A seqan3::option_parse_result whether parsing was successful or not. + * \returns A sharg::option_parse_result whether parsing was successful or not. */ template //!\cond @@ -371,7 +371,7 @@ class format_parse : public format_base typename container_option_t::value_type & container_value, std::string const & in) { - SEQAN3_RETURN_TYPE_CONSTRAINT(fp.parse_option_value(container_value, in), + SHARG_RETURN_TYPE_CONSTRAINT(fp.parse_option_value(container_value, in), std::same_as, option_parse_result); } @@ -392,17 +392,17 @@ class format_parse : public format_base * \tparam option_t The option value type; must model seqan3::arithmetic. * \param[out] value Stores the parsed value. * \param[in] in The input argument to be parsed. - * \returns seqan3::option_parse_result::error if `in` could not be parsed to an arithmetic type - * via std::from_chars, seqan3::option_parse_result::overflow_error if `in` could be parsed but the - * value is too large for the respective type, and otherwise seqan3::option_parse_result::success. + * \returns sharg::option_parse_result::error if `in` could not be parsed to an arithmetic type + * via std::from_chars, sharg::option_parse_result::overflow_error if `in` could be parsed but the + * value is too large for the respective type, and otherwise sharg::option_parse_result::success. * * \details * * This function delegates to std::from_chars. */ - template + template //!\cond - requires input_stream_over + requires seqan3::input_stream_over //!\endcond option_parse_result parse_option_value(option_t & value, std::string const & in) { @@ -419,7 +419,7 @@ class format_parse : public format_base /*!\brief Tries to parse an input string into a boolean value. * \param[out] value Stores the parsed value. * \param[in] in The input argument to be parsed. - * \returns A seqan3::option_parse_result whether parsing was successful or not. + * \returns A sharg::option_parse_result whether parsing was successful or not. * * \details * @@ -447,7 +447,7 @@ class format_parse : public format_base * \param[in] option_name The name of the option whose input was parsed. * \param[in] input_value The original user input in question. * - * \throws seqan3::user_input_error if `res` was not seqan3::option_parse_result::success. + * \throws sharg::user_input_error if `res` was not sharg::option_parse_result::success. */ template void throw_on_input_error(option_parse_result const res, @@ -462,7 +462,7 @@ class format_parse : public format_base get_type_name_as_string(option_type{}) + "."}; } - if constexpr (arithmetic) + if constexpr (seqan3::arithmetic) { if (res == option_parse_result::overflow_error) { @@ -481,8 +481,8 @@ class format_parse : public format_base * \param[in] option_it The iterator where the option identifier was found. * \param[in] id The option identifier supplied on the command line. * - * \throws seqan3::too_few_arguments if the option was not followed by a value. - * \throws seqan3::user_input_error if the given option value was invalid. + * \throws sharg::too_few_arguments if the option was not followed by a value. + * \throws sharg::user_input_error if the given option value was invalid. * * \details * @@ -540,7 +540,7 @@ class format_parse : public format_base * \param[out] value Stores the value found in argv, parsed by parse_option_value. * \param[in] id The option identifier supplied on the command line. * - * \throws seqan3::option_declared_multiple_times + * \throws sharg::option_declared_multiple_times * * \details * @@ -598,7 +598,7 @@ class format_parse : public format_base /*!\brief Checks format_parse::argv for unknown options/flags. * - * \throws seqan3::unknown_option + * \throws sharg::unknown_option * * \details * @@ -640,7 +640,7 @@ class format_parse : public format_base /*!\brief Checks format_parse::argv for unknown options/flags. * - * \throws seqan3::too_many_arguments + * \throws sharg::too_many_arguments * * \details * @@ -660,12 +660,12 @@ class format_parse : public format_base * \param[out] value The variable in which to store the given command line argument. * \param[in] short_id The short identifier for the option (e.g. 'i'). * \param[in] long_id The long identifier for the option (e.g. "integer"). - * \param[in] spec Advanced option specification, see seqan3::option_spec. + * \param[in] spec Advanced option specification, see sharg::option_spec. * \param[in] validator The validator applied to the value after parsing (callable). * - * \throws seqan3::option_declared_multiple_times - * \throws seqan3::validation_error - * \throws seqan3::required_option_missing + * \throws sharg::option_declared_multiple_times + * \throws sharg::validation_error + * \throws sharg::required_option_missing * * \details * @@ -730,10 +730,10 @@ class format_parse : public format_base * \param[out] value The variable in which to store the given command line argument. * \param[in] validator The validator applied to the value after parsing (callable). * - * \throws seqan3::argument_parser_error - * \throws seqan3::too_few_arguments - * \throws seqan3::validation_error - * \throws seqan3::design_error + * \throws sharg::argument_parser_error + * \throws sharg::too_few_arguments + * \throws sharg::validation_error + * \throws sharg::design_error * * \details * @@ -812,4 +812,4 @@ class format_parse : public format_base std::vector::iterator end_of_options_it; }; -} // namespace seqan3 +} // namespace sharg diff --git a/include/sharg/detail/terminal.hpp b/include/sharg/detail/terminal.hpp index fe36acaf..32256e6e 100644 --- a/include/sharg/detail/terminal.hpp +++ b/include/sharg/detail/terminal.hpp @@ -2,7 +2,7 @@ // Copyright (c) 2006-2021, Knut Reinert & Freie Universität Berlin // Copyright (c) 2016-2021, Knut Reinert & MPI für molekulare Genetik // This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License -// shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md +// shipped with this file and also available at: https://github.com/seqan/sharg-parser/blob/master/LICENSE.md // ----------------------------------------------------------------------------------------------------- /*!\file @@ -25,7 +25,7 @@ #include -namespace seqan3::detail +namespace sharg::detail { // ---------------------------------------------------------------------------- diff --git a/include/sharg/detail/version_check.hpp b/include/sharg/detail/version_check.hpp index e5098ae2..928667aa 100644 --- a/include/sharg/detail/version_check.hpp +++ b/include/sharg/detail/version_check.hpp @@ -2,7 +2,7 @@ // Copyright (c) 2006-2021, Knut Reinert & Freie Universität Berlin // Copyright (c) 2016-2021, Knut Reinert & MPI für molekulare Genetik // This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License -// shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md +// shipped with this file and also available at: https://github.com/seqan/sharg-parser/blob/master/LICENSE.md // ----------------------------------------------------------------------------------------------------- /*!\file @@ -28,7 +28,7 @@ #include #include -namespace seqan3::detail +namespace sharg::detail { // --------------------------------------------------------------------------------------------------------------------- @@ -36,7 +36,7 @@ namespace seqan3::detail // --------------------------------------------------------------------------------------------------------------------- /*!\brief Writes a timestamp file and performs the server call to get the newest version information. - * \param[in] command The system command as a string. See seqan3::detail::version_checker::command for details. + * \param[in] command The system command as a string. See sharg::detail::version_checker::command for details. * \param[in] prom A promise object used to track the detached thread which executes this command. * * This function performs a https server request by executing a hard coded command (string) as a system call. @@ -102,7 +102,7 @@ class version_checker //!\} /*!\brief Initialises the version_checker with the application name and version. - * \param[in] prom The promise to track the state of the detached thread which calls seqan3::detail::call_server. + * \param[in] prom The promise to track the state of the detached thread which calls sharg::detail::call_server. * * The operator performs the following steps: * @@ -117,12 +117,12 @@ class version_checker * **Debug mode** (directed at the developer of the application) * * If the app is unregistered (no version information is available at the server) the developer will be * notified that he has the possibility of registering his application with us - * (see seqan3::version_checker::message_unregistered_app). + * (see sharg::version_checker::message_unregistered_app). * * If the current seqan version is smaller then the one returned by the server call, the developer is notified - * that he may update to the newest seqan3 version (see seqan3::version_checker::message_seqan3_update). + * that he may update to the newest seqan3 version (see sharg::version_checker::message_seqan3_update). * * If the current app version is greater than the one returned by the server call, we assume that the * developer has released a new version and is notified to send us the new version - * (see seqan3::version_checker::message_registered_app_update). + * (see sharg::version_checker::message_registered_app_update). * **Release mode** (directed at the user of the application): * * If the current app version is lower than the one returned by the server call, the user is notified that * a newer version exists. @@ -254,7 +254,7 @@ class version_checker // check if files can be written inside dir path dummy = tmp_path / "dummy.txt"; std::ofstream file{dummy}; - detail::safe_filesystem_entry file_guard{dummy}; + seqan3::detail::safe_filesystem_entry file_guard{dummy}; bool is_open = file.is_open(); bool is_good = file.good(); @@ -279,7 +279,7 @@ class version_checker * If the developer says no, it rules out all following decisions (even if the user specified --version-check true). * No cookie is ever written. * - * If the environment variable SEQAN3_NO_VERSION_CHECK is set no version check is done (rules out all following). + * If the environment variable SHARG_NO_VERSION_CHECK is set no version check is done (rules out all following). * No cookie is written. * * If the user explicitly uses the --version-check option (user_approval is set) it rules out all following @@ -291,7 +291,7 @@ class version_checker * * ASK: Ask the user or default the decision once a day. * * If the cookie content is "ASK" and the timestamp is older than a day we ask the user, - * if possible (seqan3::detail::is_terminal()), what he wants to do, set the according cookie for the next time + * if possible (sharg::detail::is_terminal()), what he wants to do, set the according cookie for the next time * and continue. If we cannot ask the user, the default kicks in (do the check). */ bool decide_if_check_is_performed(update_notifications developer_approval, std::optional user_approval) @@ -299,7 +299,7 @@ class version_checker if (developer_approval == update_notifications::off) return false; - if (std::getenv("SEQAN3_NO_VERSION_CHECK") != nullptr) // environment variable was set + if (std::getenv("SHARG_NO_VERSION_CHECK") != nullptr) // environment variable was set return false; if (user_approval.has_value()) @@ -485,7 +485,7 @@ class version_checker } /*!\brief Parses a version string into an array of length 3. - * \param[in] str The version string that must match seqan3::detail::version_regex. + * \param[in] str The version string that must match sharg::detail::version_regex. */ std::array get_numbers_from_version_string(std::string const & str) const { @@ -522,4 +522,4 @@ class version_checker } }; -} // namespace seqan3 +} // namespace sharg diff --git a/include/sharg/exceptions.hpp b/include/sharg/exceptions.hpp index bd980f78..41d047ea 100644 --- a/include/sharg/exceptions.hpp +++ b/include/sharg/exceptions.hpp @@ -2,7 +2,7 @@ // Copyright (c) 2006-2021, Knut Reinert & Freie Universität Berlin // Copyright (c) 2016-2021, Knut Reinert & MPI für molekulare Genetik // This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License -// shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md +// shipped with this file and also available at: https://github.com/seqan/sharg-parser/blob/master/LICENSE.md // ----------------------------------------------------------------------------------------------------- /*!\file @@ -14,9 +14,9 @@ #include -#include +#include -namespace seqan3 +namespace sharg { /*!\brief Argument parser exception that is thrown whenever there is an error * while parsing the command line arguments. @@ -148,4 +148,4 @@ class design_error : public argument_parser_error design_error(std::string const & s) : argument_parser_error(s) {} }; -} // namespace seqan3 +} // namespace sharg diff --git a/include/sharg/platform.hpp b/include/sharg/platform.hpp index 9f04c647..ea1d4e9b 100644 --- a/include/sharg/platform.hpp +++ b/include/sharg/platform.hpp @@ -61,3 +61,12 @@ static_assert(seqan3::seqan3_version_minor >= 1, "SeqAn >= 3.1 is required by SH #ifndef SHARG_DOXYGEN_ONLY # define SHARG_DOXYGEN_ONLY(x) #endif + +//!\brief Same as writing `{expression} -> concept_name` in a concept definition. +#if defined(__GNUC__) && (__GNUC__ < 10) +# define SHARG_RETURN_TYPE_CONSTRAINT(expression, concept_name, ...) \ + {expression}; requires concept_name +#else +# define SHARG_RETURN_TYPE_CONSTRAINT(expression, concept_name, ...) \ + {expression} -> concept_name<__VA_ARGS__> +#endif diff --git a/include/sharg/validators.hpp b/include/sharg/validators.hpp index 9b3f9efc..1e03a9b2 100644 --- a/include/sharg/validators.hpp +++ b/include/sharg/validators.hpp @@ -2,7 +2,7 @@ // Copyright (c) 2006-2021, Knut Reinert & Freie Universität Berlin // Copyright (c) 2016-2021, Knut Reinert & MPI für molekulare Genetik // This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License -// shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md +// shipped with this file and also available at: https://github.com/seqan/sharg-parser/blob/master/LICENSE.md // ----------------------------------------------------------------------------------------------------- /*!\file @@ -31,68 +31,27 @@ #include #include -namespace seqan3 +namespace sharg { -/*!\interface seqan3::validator <> +/*!\concept sharg::validator * \brief The concept for option validators passed to add_option/positional_option. * \ingroup argument_parser * * \details * - * When adding (positional) options to the seqan3::argument_parser you may pass a + * When adding (positional) options to the sharg::argument_parser you may pass a * [function object](https://en.cppreference.com/w/cpp/named_req/FunctionObject) that models - * seqan3::validator which checks the option value provided by the user for some constraint. + * sharg::validator which checks the option value provided by the user for some constraint. * - * SeqAn provides several common-use-case validators, e.g. the seqan3::arithmetic_range_validator. + * SeqAn provides several common-use-case validators, e.g. the sharg::arithmetic_range_validator. * * \include test/snippet/argument_parser/validators_2.cpp * * You can learn more about SeqAn validators in our tutorial \ref section_validation. * * To implement your own validator please refer to the detailed concept description below. - * - * ### Concepts and doxygen - * - * The requirements for this concept are given as related functions and type traits. - * Types that satisfy this concept are shown as "implementing this interface". - */ -/*!\name Requirements for seqan3::validator - * \brief You can expect these (meta-)functions on all types that implement seqan3::validator. - * \{ - */ -/*!\typedef using option_value_type - * \brief The type of value on which the validator is called on. - * \relates seqan3::validator - * - * \details - * \attention This is a concept requirement, not an actual typedef (however types satisfying this concept - * will provide an implementation). - */ -/*!\fn void operator()(option_value_type const & cmp) const - * \brief Validates the value 'cmp' and throws a seqan3::validation_error on failure. - * \tparam option_value_type The type of the value to be validated. - * \param[in,out] cmp The value to be validated. - * \relates seqan3::validator - * \throws seqan3::validation_error if value 'cmp' does not pass validation. - * - * \details - * \attention This is a concept requirement, not an actual function (however types satisfying this concept - * will provide an implementation). */ -/*!\fn std::string get_help_page_message() const - * \brief Returns a message that can be appended to the (positional) options help page info. - * \relates seqan3::validator - * \returns A string that contains information on the performed validation. - * - * \details - * \attention This is a concept requirement, not an actual function (however types satisfying this concept - * will provide an implementation). - * - * \remark For a complete overview, take a look at \ref argument_parser - */ -//!\} -//!\cond template concept validator = std::copyable> && requires(validator_type validator, @@ -100,27 +59,26 @@ concept validator = std::copyable> && { typename std::remove_reference_t::option_value_type; - SEQAN3_RETURN_TYPE_CONSTRAINT(validator(value), std::same_as, void); - SEQAN3_RETURN_TYPE_CONSTRAINT(validator.get_help_page_message(), std::same_as, std::string); + SHARG_RETURN_TYPE_CONSTRAINT(validator(value), std::same_as, void); + SHARG_RETURN_TYPE_CONSTRAINT(validator.get_help_page_message(), std::same_as, std::string); }; -//!\endcond /*!\brief A validator that checks whether a number is inside a given range. * \ingroup argument_parser - * \implements seqan3::validator + * \implements sharg::validator * \tparam option_value_t The value type of the range; must model seqan3::arithmetic . * * \details * * On construction, the validator must receive a maximum and a minimum number. - * The class than acts as a functor, that throws a seqan3::validation_error + * The class than acts as a functor, that throws a sharg::validation_error * exception whenever a given value does not lie inside the given min/max range. * * \include test/snippet/argument_parser/validators_1.cpp * * \remark For a complete overview, take a look at \ref argument_parser */ -template +template class arithmetic_range_validator { public: @@ -137,23 +95,23 @@ class arithmetic_range_validator /*!\brief Tests whether cmp lies inside [`min`, `max`]. * \param cmp The input value to check. - * \throws seqan3::validation_error + * \throws sharg::validation_error */ void operator()(option_value_type const & cmp) const { if (!((cmp <= max) && (cmp >= min))) - throw validation_error{detail::to_string("Value ", cmp, " is not in range [", min, ",", max, "].")}; + throw validation_error{seqan3::detail::to_string("Value ", cmp, " is not in range [", min, ",", max, "].")}; } /*!\brief Tests whether every element in \p range lies inside [`min`, `max`]. * \tparam range_type The type of range to check; must model std::ranges::forward_range. The value type must model * seqan3::arithmetic. * \param range The input range to iterate over and check every element. - * \throws seqan3::validation_error + * \throws sharg::validation_error */ template //!\cond - requires arithmetic> + requires seqan3::arithmetic> //!\endcond void operator()(range_type const & range) const { @@ -163,7 +121,7 @@ class arithmetic_range_validator //!\brief Returns a message that can be appended to the (positional) options help page info. std::string get_help_page_message() const { - return detail::to_string("Value must be in range [", min, ",", max, "]."); + return seqan3::detail::to_string("Value must be in range [", min, ",", max, "]."); } private: @@ -176,13 +134,13 @@ class arithmetic_range_validator /*!\brief A validator that checks whether a value is inside a list of valid values. * \ingroup argument_parser - * \implements seqan3::validator - * \tparam option_value_t \copybrief seqan3::value_list_validator::option_value_type + * \implements sharg::validator + * \tparam option_value_t \copybrief sharg::value_list_validator::option_value_type * * \details * * On construction, the validator must receive a range or parameter pack of valid values. - * The class than acts as a functor, that throws a seqan3::validation_error + * The class than acts as a functor, that throws a sharg::validation_error * exception whenever a given value is not in the given list. * * \note In order to simplify the chaining of validators, the option value type is deduced to `std::string` if the @@ -242,18 +200,18 @@ class value_list_validator /*!\brief Tests whether cmp lies inside values. * \param cmp The input value to check. - * \throws seqan3::validation_error + * \throws sharg::validation_error */ void operator()(option_value_type const & cmp) const { if (!(std::find(values.begin(), values.end(), cmp) != values.end())) - throw validation_error{detail::to_string("Value ", cmp, " is not one of ", std::views::all(values), ".")}; + throw validation_error{seqan3::detail::to_string("Value ", cmp, " is not one of ", std::views::all(values), ".")}; } /*!\brief Tests whether every element in \p range lies inside values. * \tparam range_type The type of range to check; must model std::ranges::forward_range. * \param range The input range to iterate over and check every element. - * \throws seqan3::validation_error + * \throws sharg::validation_error */ template //!\cond @@ -267,7 +225,7 @@ class value_list_validator //!\brief Returns a message that can be appended to the (positional) options help page info. std::string get_help_page_message() const { - return detail::to_string("Value must be one of ", std::views::all(values), "."); + return seqan3::detail::to_string("Value must be one of ", std::views::all(values), "."); } private: @@ -277,7 +235,7 @@ class value_list_validator }; /*!\brief Type deduction guides - * \relates seqan3::value_list_validator + * \relates sharg::value_list_validator * \{ */ //!\brief Given a parameter pack of types that are convertible to std::string, delegate to value type std::string. @@ -314,10 +272,10 @@ value_list_validator(range_type && rng) -> value_list_validator //!\cond @@ -369,7 +327,7 @@ class file_validator_base protected: /*!\brief Validates the given filename path based on the specified extensions. * \param path The filename path. - * \throws seqan3::validation_error if the specified extensions don't match the given path, or + * \throws sharg::validation_error if the specified extensions don't match the given path, or * std::filesystem::filesystem_error on underlying OS API errors. */ void validate_filename(std::filesystem::path const & path) const @@ -380,7 +338,7 @@ class file_validator_base // Check if extension is available. if (!path.has_extension()) - throw validation_error{detail::to_string("The given filename ", path.string(), " has no extension. Expected" + throw validation_error{seqan3::detail::to_string("The given filename ", path.string(), " has no extension. Expected" " one of the following valid extensions:", extensions, "!")}; std::string file_path{path.filename().string()}; @@ -401,7 +359,7 @@ class file_validator_base // Check if requested extension is present. if (std::ranges::find_if(extensions, case_insensitive_ends_with) == extensions.end()) { - throw validation_error{detail::to_string("Expected one of the following valid extensions: ", extensions, + throw validation_error{seqan3::detail::to_string("Expected one of the following valid extensions: ", extensions, "! Got ", all_extensions, " instead!")}; } } @@ -409,7 +367,7 @@ class file_validator_base /*!\brief Checks if the given path is readable. * \param path The path to check. * \returns `true` if readable, otherwise `false`. - * \throws seqan3::validation_error if the path is not readable, or + * \throws sharg::validation_error if the path is not readable, or * std::filesystem::filesystem_error on underlying OS API errors. */ void validate_readability(std::filesystem::path const & path) const @@ -420,37 +378,37 @@ class file_validator_base std::error_code ec{}; std::filesystem::directory_iterator{path, ec}; // if directory iterator cannot be created, ec will be set. if (static_cast(ec)) - throw validation_error{detail::to_string("Cannot read the directory ", path ,"!")}; + throw validation_error{seqan3::detail::to_string("Cannot read the directory ", path ,"!")}; } else { // Must be a regular file. if (!std::filesystem::is_regular_file(path)) - throw validation_error{detail::to_string("Expected a regular file ", path, "!")}; + throw validation_error{seqan3::detail::to_string("Expected a regular file ", path, "!")}; std::ifstream file{path}; if (!file.is_open() || !file.good()) - throw validation_error{detail::to_string("Cannot read the file ", path, "!")}; + throw validation_error{seqan3::detail::to_string("Cannot read the file ", path, "!")}; } } /*!\brief Checks if the given path is writable. * \param path The path to check. * \returns `true` if writable, otherwise `false`. - * \throws seqan3::validation_error if the file could not be opened for writing, or + * \throws sharg::validation_error if the file could not be opened for writing, or * std::filesystem::filesystem_error on underlying OS API errors. */ void validate_writeability(std::filesystem::path const & path) const { std::ofstream file{path}; - detail::safe_filesystem_entry file_guard{path}; + seqan3::detail::safe_filesystem_entry file_guard{path}; bool is_open = file.is_open(); bool is_good = file.good(); file.close(); if (!is_good || !is_open) - throw validation_error{detail::to_string("Cannot write ", path, "!")}; + throw validation_error{seqan3::detail::to_string("Cannot write ", path, "!")}; file_guard.remove(); } @@ -461,7 +419,7 @@ class file_validator_base if (extensions.empty()) return ""; else - return detail::to_string(" Valid file extensions are: [", extensions | views::join_with(std::string{", "}), "]."); + return seqan3::detail::to_string(" Valid file extensions are: [", extensions | seqan3::views::join_with(std::string{", "}), "]."); } /*!\brief Helper function that checks if a string is a suffix of another string. Case insensitive. @@ -487,21 +445,21 @@ class file_validator_base /*!\brief A validator that checks if a given path is a valid input file. * \ingroup argument_parser - * \implements seqan3::validator + * \implements sharg::validator * \tparam file_t The type of the file to get the valid extensions for; `void` on default. * * \details * * On construction, the validator can receive a list (std::vector over std::string) of valid file extensions. - * The class acts as a functor that throws a seqan3::validation_error exception whenever a given filename's + * The class acts as a functor that throws a sharg::validation_error exception whenever a given filename's * extension (std::filesystem::path) is not in the given list of valid file extensions, if the file does not exist, or * if the file does not have the proper read permissions. * * \include test/snippet/argument_parser/validators_input_file.cpp * - * The valid extensions can also be obtained from a seqan3 formatted file type, e.g. seqan3::sequence_input_file, if + * The valid extensions can also be obtained from a seqan3 formatted file type, e.g. sharg::sequence_input_file, if * it is given as template argument to this class. The following snippet demonstrates the different ways to instantiate - * the seqan3::input_file_validator. + * the sharg::input_file_validator. * * \include test/snippet/argument_parser/validators_input_file_ext_from_file.cpp * @@ -514,7 +472,7 @@ class input_file_validator : public file_validator_base { public: - static_assert(std::same_as || detail::has_type_valid_formats, + static_assert(std::same_as || seqan3::detail::has_type_valid_formats, "Expected either a template type with a static member called valid_formats (a file type) or void."); // Import from base class. @@ -535,7 +493,7 @@ class input_file_validator : public file_validator_base input_file_validator() { if constexpr (!std::same_as) - file_validator_base::extensions = detail::valid_file_extensions(); + file_validator_base::extensions = seqan3::detail::valid_file_extensions(); } input_file_validator(input_file_validator const &) = default; //!< Defaulted. @@ -570,7 +528,7 @@ class input_file_validator : public file_validator_base /*!\brief Tests whether path is an existing regular file and is readable. * \param file The input value to check. - * \throws seqan3::validation_error if the validation process failed. Might be nested with + * \throws sharg::validation_error if the validation process failed. Might be nested with * std::filesystem::filesystem_error on unhandled OS API errors. */ virtual void operator()(std::filesystem::path const & file) const override @@ -578,7 +536,7 @@ class input_file_validator : public file_validator_base try { if (!std::filesystem::exists(file)) - throw validation_error{detail::to_string("The file ", file, " does not exist!")}; + throw validation_error{seqan3::detail::to_string("The file ", file, " does not exist!")}; // Check if file is regular and can be opened for reading. validate_readability(file); @@ -617,25 +575,25 @@ enum class output_file_open_options /*!\brief A validator that checks if a given path is a valid output file. * \ingroup argument_parser - * \implements seqan3::validator + * \implements sharg::validator * \tparam file_t The type of the file to get the valid extensions for; `void` on default. * * \details * * On construction, the validator can receive a list (std::vector over std::string) of valid file extensions. - * The class acts as a functor that throws a seqan3::validation_error exception whenever a given filename's extension + * The class acts as a functor that throws a sharg::validation_error exception whenever a given filename's extension * (std::string) is not in the given list of valid file extensions, or if the parent path does not have the proper * writer permissions. - * In addition, the validator receives a seqan3::output_file_open_options which allows you to specify what to do if your - * output file already exists. seqan3::output_file_open_options::create_new will throw a seqan3::validation_error - * exception if it already exists and seqan3::output_file_open_options::open_or_create will skip this check (that means + * In addition, the validator receives a sharg::output_file_open_options which allows you to specify what to do if your + * output file already exists. sharg::output_file_open_options::create_new will throw a sharg::validation_error + * exception if it already exists and sharg::output_file_open_options::open_or_create will skip this check (that means * you are allowed to overwrite the existing file). * * \include test/snippet/argument_parser/validators_output_file.cpp * - * The valid extensions can also be obtained from a seqan3 formatted file type, e.g. seqan3::sequence_input_file, if + * The valid extensions can also be obtained from a seqan3 formatted file type, e.g. sharg::sequence_input_file, if * it is given as template argument to this class. The following snippet demonstrates the different ways to instantiate - * the seqan3::output_file_validator. + * the sharg::output_file_validator. * * \include test/snippet/argument_parser/validators_output_file_ext_from_file.cpp * @@ -647,7 +605,7 @@ template class output_file_validator : public file_validator_base { public: - static_assert(std::same_as || detail::has_type_valid_formats, + static_assert(std::same_as || seqan3::detail::has_type_valid_formats, "Expected either a template type with a static member called valid_formats (a file type) or void."); // Import from base class. @@ -657,7 +615,7 @@ class output_file_validator : public file_validator_base * \{ */ - //!\copydoc seqan3::input_file_validator::input_file_validator() + //!\copydoc sharg::input_file_validator::input_file_validator() output_file_validator() : output_file_validator{output_file_open_options::create_new} {} @@ -668,10 +626,10 @@ class output_file_validator : public file_validator_base virtual ~output_file_validator() = default; //!< Virtual Destructor. /*!\brief Constructs from a given overwrite mode and a list of valid extensions. - * \param[in] mode A seqan3::output_file_open_options indicating whether the validator throws if a file already + * \param[in] mode A sharg::output_file_open_options indicating whether the validator throws if a file already exists. * \param[in] extensions The valid extensions to validate for. Defaults to - * seqan3::output_file_validator::default_extensions. + * sharg::output_file_validator::default_extensions. */ explicit output_file_validator(output_file_open_options const mode, std::vector extensions = default_extensions()) @@ -695,7 +653,7 @@ class output_file_validator : public file_validator_base static std::vector default_extensions() { if constexpr (!std::same_as) - return detail::valid_file_extensions(); + return seqan3::detail::valid_file_extensions(); return {}; } @@ -704,7 +662,7 @@ class output_file_validator : public file_validator_base /*!\brief Tests whether path is does not already exists and is writable. * \param file The input value to check. - * \throws seqan3::validation_error if the validation process failed. Might be nested with + * \throws sharg::validation_error if the validation process failed. Might be nested with * std::filesystem::filesystem_error on unhandled OS API errors. */ virtual void operator()(std::filesystem::path const & file) const override @@ -712,7 +670,7 @@ class output_file_validator : public file_validator_base try { if ((mode == output_file_open_options::create_new) && std::filesystem::exists(file)) - throw validation_error{detail::to_string("The file ", file, " already exists!")}; + throw validation_error{seqan3::detail::to_string("The file ", file, " already exists!")}; // Check if file has any write permissions. validate_writeability(file); @@ -748,11 +706,11 @@ class output_file_validator : public file_validator_base /*!\brief A validator that checks if a given path is a valid input directory. * \ingroup argument_parser - * \implements seqan3::validator + * \implements sharg::validator * * \details * - * The class acts as a functor that throws a seqan3::validation_error exception whenever a given directory + * The class acts as a functor that throws a sharg::validation_error exception whenever a given directory * (std::filesystem::path) does not exist, the specified path is not a directory, or if the directory is not * readable. * @@ -787,7 +745,7 @@ class input_directory_validator : public file_validator_base /*!\brief Tests whether path is an existing directory and is readable. * \param dir The input value to check. - * \throws seqan3::validation_error if the validation process failed. Might be nested with + * \throws sharg::validation_error if the validation process failed. Might be nested with * std::filesystem::filesystem_error on unhandled OS API errors. */ virtual void operator()(std::filesystem::path const & dir) const override @@ -795,10 +753,10 @@ class input_directory_validator : public file_validator_base try { if (!std::filesystem::exists(dir)) - throw validation_error{detail::to_string("The directory ", dir, " does not exists!")}; + throw validation_error{seqan3::detail::to_string("The directory ", dir, " does not exists!")}; if (!std::filesystem::is_directory(dir)) - throw validation_error{detail::to_string("The path ", dir, " is not a directory!")}; + throw validation_error{seqan3::detail::to_string("The path ", dir, " is not a directory!")}; // Check if directory has any read permissions. validate_readability(dir); @@ -818,17 +776,17 @@ class input_directory_validator : public file_validator_base //!\brief Returns a message that can be appended to the (positional) options help page info. std::string get_help_page_message() const { - return detail::to_string("An existing, readable path for the input directory."); + return seqan3::detail::to_string("An existing, readable path for the input directory."); } }; /*!\brief A validator that checks if a given path is a valid output directory. * \ingroup argument_parser - * \implements seqan3::validator + * \implements sharg::validator * * \details * - * The class acts as a functor that throws a seqan3::validation_error exception whenever a given path + * The class acts as a functor that throws a sharg::validation_error exception whenever a given path * (std::filesystem::path) is not writable. This can happen if either the parent path does not exists, or the * path doesn't have the proper write permissions. * @@ -863,7 +821,7 @@ class output_directory_validator : public file_validator_base /*!\brief Tests whether path is writable. * \param dir The input value to check. - * \throws seqan3::validation_error if the validation process failed. Might be nested with + * \throws sharg::validation_error if the validation process failed. Might be nested with * std::filesystem::filesystem_error on unhandled OS API errors. */ virtual void operator()(std::filesystem::path const & dir) const override @@ -874,13 +832,13 @@ class output_directory_validator : public file_validator_base std::filesystem::create_directory(dir, ec); // does nothing and is not treated as error if path already exists. // if error code was set or if dummy.txt could not be created within the output dir, throw an error. if (static_cast(ec)) - throw validation_error{detail::to_string("Cannot create directory: ", dir, "!")}; + throw validation_error{seqan3::detail::to_string("Cannot create directory: ", dir, "!")}; try { if (!dir_exists) { - detail::safe_filesystem_entry dir_guard{dir}; + seqan3::detail::safe_filesystem_entry dir_guard{dir}; validate_writeability(dir / "dummy.txt"); dir_guard.remove_all(); } @@ -904,13 +862,13 @@ class output_directory_validator : public file_validator_base //!\brief Returns a message that can be appended to the (positional) options help page info. std::string get_help_page_message() const { - return detail::to_string("A valid path for the output directory."); + return seqan3::detail::to_string("A valid path for the output directory."); } }; /*!\brief A validator that checks if a matches a regular expression pattern. * \ingroup argument_parser - * \implements seqan3::validator + * \implements sharg::validator * * \details * @@ -920,7 +878,7 @@ class output_directory_validator : public file_validator_base * Note: A regex_match will only return true if the strings matches the pattern * completely (in contrast to regex_search which also matches substrings). * - * The class than acts as a functor, that throws a seqan3::validation_error + * The class than acts as a functor, that throws a sharg::validation_error * exception whenever string does not match the pattern. * * \include test/snippet/argument_parser/validators_4.cpp @@ -942,20 +900,20 @@ class regex_validator /*!\brief Tests whether cmp lies inside values. * \param[in] cmp The value to validate. - * \throws seqan3::validation_error + * \throws sharg::validation_error */ void operator()(option_value_type const & cmp) const { std::regex rgx(pattern); if (!std::regex_match(cmp, rgx)) - throw validation_error{detail::to_string("Value ", cmp, " did not match the pattern ", pattern, ".")}; + throw validation_error{seqan3::detail::to_string("Value ", cmp, " did not match the pattern ", pattern, ".")}; } /*!\brief Tests whether every filename in list v matches the pattern. * \tparam range_type The type of range to check; must model std::ranges::forward_range and the value type must * be convertible to std::string. * \param v The input range to iterate over and check every element. - * \throws seqan3::validation_error + * \throws sharg::validation_error */ template //!\cond @@ -973,7 +931,7 @@ class regex_validator //!\brief Returns a message that can be appended to the (positional) options help page info. std::string get_help_page_message() const { - return detail::to_string("Value must match the pattern '", pattern, "'."); + return seqan3::detail::to_string("Value must match the pattern '", pattern, "'."); } private: @@ -986,7 +944,7 @@ namespace detail /*!\brief Validator that always returns true. * \ingroup argument_parser - * \implements seqan3::validator + * \implements sharg::validator * \tparam option_value_t Must be a (container of) arithmetic type(s). * * \details @@ -1015,12 +973,12 @@ struct default_validator /*!\brief A helper struct to chain validators recursively via the pipe operator. *\ingroup argument_parser - *\implements seqan3::validator + *\implements sharg::validator * *\details * * Note that both validators must operate on the same option_value_type in order to - * avoid unexpected behaviour and ensure that the seqan3::argument_parser::add_option + * avoid unexpected behaviour and ensure that the sharg::argument_parser::add_option * call is well-formed. (add_option(val, ...., validator) requires * that val is of same type as validator::option_value_type). * @@ -1079,7 +1037,7 @@ class validator_chain_adaptor //!\brief Returns a message that can be appended to the (positional) options help page info. std::string get_help_page_message() const { - return detail::to_string(vali1.get_help_page_message(), " ", vali2.get_help_page_message()); + return seqan3::detail::to_string(vali1.get_help_page_message(), " ", vali2.get_help_page_message()); } private: @@ -1094,10 +1052,10 @@ class validator_chain_adaptor /*!\brief Enables the chaining of validators. * \ingroup argument_parser * \tparam validator1_type The type of the fist validator; - * Must satisfy the seqan3::validator and the + * Must satisfy the sharg::validator and the * same option_value_type as the second validator type. * \tparam validator2_type The type of the second validator; - * Must satisfy the seqan3::validator and the + * Must satisfy the sharg::validator and the * same option_value_type as the fist validator type. * \param[in] vali1 The first validator to chain. * \param[in] vali2 The second validator to chain. @@ -1110,8 +1068,8 @@ class validator_chain_adaptor * * For example you may want a file name that only accepts absolute paths but * also must have one out of some given file extensions. - * For this purpose you can chain a seqan3::regex_validator to a - * seqan3::input_file_validator like this: + * For this purpose you can chain a sharg::regex_validator to a + * sharg::input_file_validator like this: * * \include test/snippet/argument_parser/validators_chaining.cpp * @@ -1131,4 +1089,4 @@ auto operator|(validator1_type && vali1, validator2_type && vali2) std::forward(vali2)}; } -} // namespace seqan3 +} // namespace sharg diff --git a/test/snippet/CMakeLists.txt b/test/snippet/CMakeLists.txt index eb3716df..1608a3a3 100644 --- a/test/snippet/CMakeLists.txt +++ b/test/snippet/CMakeLists.txt @@ -2,7 +2,7 @@ # Copyright (c) 2006-2021, Knut Reinert & Freie Universität Berlin # Copyright (c) 2016-2021, Knut Reinert & MPI für molekulare Genetik # This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License -# shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md +# shipped with this file and also available at: https://github.com/seqan/sharg-parser/blob/master/LICENSE.md # ----------------------------------------------------------------------------------------------------- cmake_minimum_required (VERSION 3.10) @@ -35,7 +35,7 @@ macro (sharg_snippet test_name_prefix snippet snippet_base_path) add_test (NAME "${snippet_test_target}" COMMAND ${target}) # disable version checker, as it interferes with comparing the snippet output - set_tests_properties ("${snippet_test_target}" PROPERTIES ENVIRONMENT SEQAN3_NO_VERSION_CHECK=0) + set_tests_properties ("${snippet_test_target}" PROPERTIES ENVIRONMENT SHARG_NO_VERSION_CHECK=0) set (snippet_compare_test_target "${test_name_prefix}/${snippet_test_name}_snippet_cmp_output") @@ -46,7 +46,7 @@ macro (sharg_snippet test_name_prefix snippet snippet_base_path) -P "${CMAKE_SOURCE_DIR}/../../lib/seqan3/test/snippet/compare_snippet_output.cmake") # disable version checker, as it interferes with comparing the snippet output - set_tests_properties ("${snippet_compare_test_target}" PROPERTIES ENVIRONMENT SEQAN3_NO_VERSION_CHECK=0) + set_tests_properties ("${snippet_compare_test_target}" PROPERTIES ENVIRONMENT SHARG_NO_VERSION_CHECK=0) unset (snippet_target_name) unset (snippet_test_name) diff --git a/test/snippet/argument_parser_1.cpp b/test/snippet/argument_parser_1.cpp index 26d9cef2..4cab2e9b 100644 --- a/test/snippet/argument_parser_1.cpp +++ b/test/snippet/argument_parser_1.cpp @@ -3,7 +3,7 @@ int main(int argc, char ** argv) { - seqan3::argument_parser myparser{"Grade-Average", argc, argv}; // initialize + sharg::argument_parser myparser{"Grade-Average", argc, argv}; // initialize std::string name{"Max Muster"}; // define default values directly in the variable. bool bonus{false}; @@ -17,7 +17,7 @@ int main(int argc, char ** argv) { myparser.parse(); } - catch (seqan3::argument_parser_error const & ext) // the user did something wrong + catch (sharg::argument_parser_error const & ext) // the user did something wrong { std::cerr << "[PARSER ERROR] " << ext.what() << '\n'; // customize your error message return -1; diff --git a/test/snippet/argument_parser_2.cpp b/test/snippet/argument_parser_2.cpp index 7f5ab316..2a31dccb 100644 --- a/test/snippet/argument_parser_2.cpp +++ b/test/snippet/argument_parser_2.cpp @@ -3,7 +3,7 @@ int main(int argc, char ** argv) { - seqan3::argument_parser myparser{"The-Age-App", argc, argv}; // initialize + sharg::argument_parser myparser{"The-Age-App", argc, argv}; // initialize int age{30}; // define default values directly in the variable @@ -13,7 +13,7 @@ int main(int argc, char ** argv) { myparser.parse(); } - catch (seqan3::argument_parser_error const & ext) // the user did something wrong + catch (sharg::argument_parser_error const & ext) // the user did something wrong { std::cerr << "The-Age-App - [PARSER ERROR] " << ext.what() << '\n'; // customize your error message return -1; diff --git a/test/snippet/argument_parser_3.cpp b/test/snippet/argument_parser_3.cpp index 5c69fbfd..c7ec30eb 100644 --- a/test/snippet/argument_parser_3.cpp +++ b/test/snippet/argument_parser_3.cpp @@ -2,7 +2,7 @@ int main(int argc, char ** argv) { - seqan3::argument_parser myparser{"Penguin_Parade", argc, argv}; // initialize + sharg::argument_parser myparser{"Penguin_Parade", argc, argv}; // initialize myparser.info.version = "2.0.0"; myparser.info.date = "12.01.2017"; @@ -27,7 +27,7 @@ int main(int argc, char ** argv) { myparser.parse(); } - catch (seqan3::argument_parser_error const & ext) // the user did something wrong + catch (sharg::argument_parser_error const & ext) // the user did something wrong { std::cerr << ext.what() << "\n"; return -1; diff --git a/test/snippet/auxiliary.cpp b/test/snippet/auxiliary.cpp index e88043cd..71651a86 100644 --- a/test/snippet/auxiliary.cpp +++ b/test/snippet/auxiliary.cpp @@ -2,8 +2,8 @@ int main(int argc, const char ** argv) { - seqan3::argument_parser myparser{"Test", argc, argv}; + sharg::argument_parser myparser{"Test", argc, argv}; std::string myvar{"Example"}; myparser.add_option(myvar, 's', "special-op", "You know what you doin'?", - seqan3::option_spec::advanced); + sharg::option_spec::advanced); } diff --git a/test/snippet/custom_argument_parsing_enumeration.cpp b/test/snippet/custom_argument_parsing_enumeration.cpp index d8072cdc..839b264a 100644 --- a/test/snippet/custom_argument_parsing_enumeration.cpp +++ b/test/snippet/custom_argument_parsing_enumeration.cpp @@ -3,9 +3,9 @@ #include #include -namespace seqan3::custom +namespace sharg::custom { -// Specialise the seqan3::custom::argument_parsing data structure to enable parsing of std::errc. +// Specialise the sharg::custom::argument_parsing data structure to enable parsing of std::errc. template <> struct argument_parsing { @@ -19,25 +19,25 @@ struct argument_parsing }; }; -} // namespace seqan3::custom +} // namespace sharg::custom int main(int argc, char const * argv[]) { std::errc value{}; - seqan3::argument_parser parser{"my_program", argc, argv}; + sharg::argument_parser parser{"my_program", argc, argv}; // Because of the argument_parsing struct and // the static member function enumeration_names // you can now add an option that takes a value of type std::errc: - parser.add_option(value, 'e', "errc", "Give me a std::errc value.", seqan3::option_spec::standard, - seqan3::value_list_validator{(seqan3::enumeration_names | std::views::values)}); + parser.add_option(value, 'e', "errc", "Give me a std::errc value.", sharg::option_spec::standard, + sharg::value_list_validator{(sharg::enumeration_names | std::views::values)}); try { parser.parse(); } - catch (seqan3::argument_parser_error const & ext) // the user did something wrong + catch (sharg::argument_parser_error const & ext) // the user did something wrong { std::cerr << "[PARSER ERROR] " << ext.what() << "\n"; // customize your error message return -1; diff --git a/test/snippet/custom_enumeration.cpp b/test/snippet/custom_enumeration.cpp index 0ac1d968..5b23ed24 100644 --- a/test/snippet/custom_enumeration.cpp +++ b/test/snippet/custom_enumeration.cpp @@ -22,18 +22,18 @@ int main(int argc, char const * argv[]) { foo::bar value{}; - seqan3::argument_parser parser{"my_program", argc, argv}; + sharg::argument_parser parser{"my_program", argc, argv}; // Because of the enumeration_names function // you can now add an option that takes a value of type bar: - parser.add_option(value, 'f', "foo", "Give me a foo value.", seqan3::option_spec::standard, - seqan3::value_list_validator{(seqan3::enumeration_names | std::views::values)}); + parser.add_option(value, 'f', "foo", "Give me a foo value.", sharg::option_spec::standard, + sharg::value_list_validator{(sharg::enumeration_names | std::views::values)}); try { parser.parse(); } - catch (seqan3::argument_parser_error const & ext) // the user did something wrong + catch (sharg::argument_parser_error const & ext) // the user did something wrong { std::cerr << "[PARSER ERROR] " << ext.what() << "\n"; // customize your error message return -1; diff --git a/test/snippet/is_option_set.cpp b/test/snippet/is_option_set.cpp index 3ec5cbeb..5642b11e 100644 --- a/test/snippet/is_option_set.cpp +++ b/test/snippet/is_option_set.cpp @@ -3,7 +3,7 @@ int main(int argc, char ** argv) { - seqan3::argument_parser myparser{"awesome-app", argc, argv}; // initialize + sharg::argument_parser myparser{"awesome-app", argc, argv}; // initialize int a{3}; myparser.add_option(a, 'a', "awesome-parameter", "Please specify an integer."); @@ -12,7 +12,7 @@ int main(int argc, char ** argv) { myparser.parse(); } - catch (seqan3::argument_parser_error const & ext) // the user did something wrong + catch (sharg::argument_parser_error const & ext) // the user did something wrong { std::cerr << "[PARSER ERROR] " << ext.what() << '\n'; // customize your error message return -1; @@ -25,7 +25,7 @@ int main(int argc, char ** argv) seqan3::debug_stream << "The user set option --awesome-parameter on the command line.\n"; // Asking for an option identifier that was not used before throws an error: - // myparser.is_option_set("foo"); // throws seqan3::design_error + // myparser.is_option_set("foo"); // throws sharg::design_error return 0; } diff --git a/test/snippet/validators_1.cpp b/test/snippet/validators_1.cpp index 84b49f22..cd2009fc 100644 --- a/test/snippet/validators_1.cpp +++ b/test/snippet/validators_1.cpp @@ -3,14 +3,14 @@ int main(int argc, const char ** argv) { - seqan3::argument_parser myparser{"Test", argc, argv}; // initialize + sharg::argument_parser myparser{"Test", argc, argv}; // initialize //![validator_call] int myint; - seqan3::arithmetic_range_validator my_validator{2, 10}; + sharg::arithmetic_range_validator my_validator{2, 10}; myparser.add_option(myint,'i',"integer","Give me a number.", - seqan3::option_spec::standard, my_validator); + sharg::option_spec::standard, my_validator); //![validator_call] // an exception will be thrown if the user specifies an integer @@ -19,7 +19,7 @@ int main(int argc, const char ** argv) { myparser.parse(); } - catch (seqan3::argument_parser_error const & ext) // the user did something wrong + catch (sharg::argument_parser_error const & ext) // the user did something wrong { std::cerr << "[PARSER ERROR] " << ext.what() << "\n"; // customize your error message return -1; diff --git a/test/snippet/validators_2.cpp b/test/snippet/validators_2.cpp index 2d4aa889..9e8636b2 100644 --- a/test/snippet/validators_2.cpp +++ b/test/snippet/validators_2.cpp @@ -3,14 +3,14 @@ int main(int argc, const char ** argv) { - seqan3::argument_parser myparser{"Test", argc, argv}; // initialize + sharg::argument_parser myparser{"Test", argc, argv}; // initialize //![validator_call] int myint; - seqan3::value_list_validator my_validator{2, 4, 6, 8, 10}; + sharg::value_list_validator my_validator{2, 4, 6, 8, 10}; myparser.add_option(myint,'i',"integer","Give me a number.", - seqan3::option_spec::standard, my_validator); + sharg::option_spec::standard, my_validator); //![validator_call] // an exception will be thrown if the user specifies an integer @@ -19,7 +19,7 @@ int main(int argc, const char ** argv) { myparser.parse(); } - catch (seqan3::argument_parser_error const & ext) // the user did something wrong + catch (sharg::argument_parser_error const & ext) // the user did something wrong { std::cerr << "[PARSER ERROR] " << ext.what() << "\n"; // customize your error message return -1; diff --git a/test/snippet/validators_3.cpp b/test/snippet/validators_3.cpp index 060eba41..5b366efe 100644 --- a/test/snippet/validators_3.cpp +++ b/test/snippet/validators_3.cpp @@ -4,13 +4,13 @@ int main(int argc, const char ** argv) { - seqan3::argument_parser myparser{"Test", argc, argv}; // initialize + sharg::argument_parser myparser{"Test", argc, argv}; // initialize //![validator_call] std::filesystem::path myfile; myparser.add_option(myfile,'f',"file","Give me a filename.", - seqan3::option_spec::standard, seqan3::input_file_validator{{"fa","fasta"}}); + sharg::option_spec::standard, sharg::input_file_validator{{"fa","fasta"}}); //![validator_call] // an exception will be thrown if the user specifies a filename @@ -20,7 +20,7 @@ int main(int argc, const char ** argv) { myparser.parse(); } - catch (seqan3::argument_parser_error const & ext) // the user did something wrong + catch (sharg::argument_parser_error const & ext) // the user did something wrong { std::cerr << "[PARSER ERROR] " << ext.what() << "\n"; // customize your error message return -1; diff --git a/test/snippet/validators_4.cpp b/test/snippet/validators_4.cpp index ebf307b2..2ae9cb5e 100644 --- a/test/snippet/validators_4.cpp +++ b/test/snippet/validators_4.cpp @@ -3,14 +3,14 @@ int main(int argc, const char ** argv) { - seqan3::argument_parser myparser{"Test", argc, argv}; // initialize + sharg::argument_parser myparser{"Test", argc, argv}; // initialize //![validator_call] std::string my_string; - seqan3::regex_validator my_validator{"[a-zA-Z]+@[a-zA-Z]+\\.com"}; + sharg::regex_validator my_validator{"[a-zA-Z]+@[a-zA-Z]+\\.com"}; myparser.add_option(my_string,'s',"str","Give me a string.", - seqan3::option_spec::standard, my_validator); + sharg::option_spec::standard, my_validator); //![validator_call] // an exception will be thrown if the user specifies a string @@ -19,7 +19,7 @@ int main(int argc, const char ** argv) { myparser.parse(); } - catch (seqan3::argument_parser_error const & ext) // the user did something wrong + catch (sharg::argument_parser_error const & ext) // the user did something wrong { std::cerr << "[PARSER ERROR] " << ext.what() << "\n"; // customize your error message return -1; diff --git a/test/snippet/validators_chaining.cpp b/test/snippet/validators_chaining.cpp index 9db27ba3..7b3c7c12 100644 --- a/test/snippet/validators_chaining.cpp +++ b/test/snippet/validators_chaining.cpp @@ -3,16 +3,16 @@ int main(int argc, const char ** argv) { - seqan3::argument_parser myparser{"Test", argc, argv}; // initialize + sharg::argument_parser myparser{"Test", argc, argv}; // initialize //![validator_call] std::string file_name; - seqan3::regex_validator absolute_path_validator{"(/[^/]+)+/.*\\.[^/\\.]+$"}; - seqan3::input_file_validator my_file_ext_validator{{"sa", "so"}}; + sharg::regex_validator absolute_path_validator{"(/[^/]+)+/.*\\.[^/\\.]+$"}; + sharg::input_file_validator my_file_ext_validator{{"sa", "so"}}; myparser.add_option(file_name, 'f', "file","Give me a file name with an absolute path.", - seqan3::option_spec::standard, absolute_path_validator | my_file_ext_validator); + sharg::option_spec::standard, absolute_path_validator | my_file_ext_validator); //![validator_call] // an exception will be thrown if the user specifies a file name @@ -21,7 +21,7 @@ int main(int argc, const char ** argv) { myparser.parse(); } - catch (seqan3::argument_parser_error const & ext) // the user did something wrong + catch (sharg::argument_parser_error const & ext) // the user did something wrong { std::cerr << "[PARSER ERROR] " << ext.what() << "\n"; // customize your error message return -1; diff --git a/test/snippet/validators_input_directory.cpp b/test/snippet/validators_input_directory.cpp index 8f6d0968..bb26a732 100644 --- a/test/snippet/validators_input_directory.cpp +++ b/test/snippet/validators_input_directory.cpp @@ -4,13 +4,13 @@ int main(int argc, const char ** argv) { - seqan3::argument_parser myparser{"Test", argc, argv}; // initialize + sharg::argument_parser myparser{"Test", argc, argv}; // initialize //! [validator_call] std::filesystem::path mydir{}; myparser.add_option(mydir, 'd', "dir", "The directory containing the input files.", - seqan3::option_spec::standard, seqan3::input_directory_validator{}); + sharg::option_spec::standard, sharg::input_directory_validator{}); //! [validator_call] // an exception will be thrown if the user specifies a directory that does not exists or has insufficient @@ -19,7 +19,7 @@ int main(int argc, const char ** argv) { myparser.parse(); } - catch (seqan3::argument_parser_error const & ext) // the user did something wrong + catch (sharg::argument_parser_error const & ext) // the user did something wrong { std::cerr << "[PARSER ERROR] " << ext.what() << "\n"; // customize your error message return -1; diff --git a/test/snippet/validators_input_file.cpp b/test/snippet/validators_input_file.cpp index 82e2ed05..8fb5475c 100644 --- a/test/snippet/validators_input_file.cpp +++ b/test/snippet/validators_input_file.cpp @@ -4,13 +4,13 @@ int main(int argc, const char ** argv) { - seqan3::argument_parser myparser{"Test", argc, argv}; // initialize + sharg::argument_parser myparser{"Test", argc, argv}; // initialize //! [validator_call] std::filesystem::path myfile{}; myparser.add_option(myfile,'f',"file","The input file containing the sequences.", - seqan3::option_spec::standard, seqan3::input_file_validator{{"fa","fasta"}}); + sharg::option_spec::standard, sharg::input_file_validator{{"fa","fasta"}}); //! [validator_call] // an exception will be thrown if the user specifies a filename @@ -19,7 +19,7 @@ int main(int argc, const char ** argv) { myparser.parse(); } - catch (seqan3::argument_parser_error const & ext) // the user did something wrong + catch (sharg::argument_parser_error const & ext) // the user did something wrong { std::cerr << "[PARSER ERROR] " << ext.what() << "\n"; // customize your error message return -1; diff --git a/test/snippet/validators_input_file_ext_from_file.cpp b/test/snippet/validators_input_file_ext_from_file.cpp index d92f8a0a..200bd438 100644 --- a/test/snippet/validators_input_file_ext_from_file.cpp +++ b/test/snippet/validators_input_file_ext_from_file.cpp @@ -5,15 +5,15 @@ int main() { // Default constructed validator has an empty extension list. - seqan3::input_file_validator validator1{}; + sharg::input_file_validator validator1{}; seqan3::debug_stream << validator1.get_help_page_message() << '\n'; // Specify your own extensions for the input file. - seqan3::input_file_validator validator2{std::vector{std::string{"exe"}, std::string{"fasta"}}}; + sharg::input_file_validator validator2{std::vector{std::string{"exe"}, std::string{"fasta"}}}; seqan3::debug_stream << validator2.get_help_page_message() << '\n'; // Give the seqan3 file type as a template argument to get all valid extensions for this file. - seqan3::input_file_validator> validator3{}; + sharg::input_file_validator> validator3{}; seqan3::debug_stream << validator3.get_help_page_message() << '\n'; return 0; diff --git a/test/snippet/validators_output_directory.cpp b/test/snippet/validators_output_directory.cpp index 66f1e738..f90cfbe8 100644 --- a/test/snippet/validators_output_directory.cpp +++ b/test/snippet/validators_output_directory.cpp @@ -4,14 +4,14 @@ int main(int argc, const char ** argv) { - seqan3::argument_parser myparser{"Test", argc, argv}; // initialize + sharg::argument_parser myparser{"Test", argc, argv}; // initialize //! [validator_call] std::filesystem::path mydir{}; myparser.add_option(mydir, 'd', "dir", "The output directory for storing the files.", - seqan3::option_spec::standard, - seqan3::output_directory_validator{}); + sharg::option_spec::standard, + sharg::output_directory_validator{}); //! [validator_call] // an exception will be thrown if the user specifies a directory that cannot be created by the filesystem either @@ -20,7 +20,7 @@ int main(int argc, const char ** argv) { myparser.parse(); } - catch (seqan3::argument_parser_error const & ext) // the user did something wrong + catch (sharg::argument_parser_error const & ext) // the user did something wrong { std::cerr << "[PARSER ERROR] " << ext.what() << "\n"; // customize your error message return -1; diff --git a/test/snippet/validators_output_file.cpp b/test/snippet/validators_output_file.cpp index 0e128204..ba1ec87c 100644 --- a/test/snippet/validators_output_file.cpp +++ b/test/snippet/validators_output_file.cpp @@ -4,20 +4,20 @@ int main(int argc, const char ** argv) { - seqan3::argument_parser myparser{"Test", argc, argv}; // initialize + sharg::argument_parser myparser{"Test", argc, argv}; // initialize //! [validator_call] std::filesystem::path myfile{}; - // Use the seqan3::output_file_open_options to indicate that you allow overwriting existing output files, ... + // Use the sharg::output_file_open_options to indicate that you allow overwriting existing output files, ... myparser.add_option(myfile, 'f', "file", "Output file containing the processed sequences.", - seqan3::option_spec::standard, - seqan3::output_file_validator{seqan3::output_file_open_options::open_or_create, {"fa","fasta"}}); + sharg::option_spec::standard, + sharg::output_file_validator{sharg::output_file_open_options::open_or_create, {"fa","fasta"}}); - // ... or that you will throw a seqan3::validation_error if the user specified output file already exists + // ... or that you will throw a sharg::validation_error if the user specified output file already exists myparser.add_option(myfile, 'g', "file2", "Output file containing the processed sequences.", - seqan3::option_spec::standard, - seqan3::output_file_validator{seqan3::output_file_open_options::create_new, {"fa","fasta"}}); + sharg::option_spec::standard, + sharg::output_file_validator{sharg::output_file_open_options::create_new, {"fa","fasta"}}); //! [validator_call] // an exception will be thrown if the user specifies a filename @@ -27,7 +27,7 @@ int main(int argc, const char ** argv) { myparser.parse(); } - catch (seqan3::argument_parser_error const & ext) // the user did something wrong + catch (sharg::argument_parser_error const & ext) // the user did something wrong { std::cerr << "[PARSER ERROR] " << ext.what() << "\n"; // customize your error message return -1; diff --git a/test/snippet/validators_output_file_ext_from_file.cpp b/test/snippet/validators_output_file_ext_from_file.cpp index 1a5ccd10..ea632dbd 100644 --- a/test/snippet/validators_output_file_ext_from_file.cpp +++ b/test/snippet/validators_output_file_ext_from_file.cpp @@ -5,18 +5,18 @@ int main() { // Default constructed validator has an empty extension list. - seqan3::output_file_validator validator1{seqan3::output_file_open_options::create_new}; + sharg::output_file_validator validator1{sharg::output_file_open_options::create_new}; seqan3::debug_stream << validator1.get_help_page_message() << '\n'; // Specify your own extensions for the output file. - seqan3::output_file_validator validator2{seqan3::output_file_open_options::create_new, + sharg::output_file_validator validator2{sharg::output_file_open_options::create_new, std::vector{std::string{"exe"}, std::string{"fasta"}}}; seqan3::debug_stream << validator2.get_help_page_message() << '\n'; // Give the seqan3 file type as a template argument to get all valid extensions for this file. - seqan3::output_file_validator> validator3 + sharg::output_file_validator> validator3 { - seqan3::output_file_open_options::create_new + sharg::output_file_open_options::create_new }; seqan3::debug_stream << validator3.get_help_page_message() << '\n'; diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt index 574df85f..a4f625f1 100644 --- a/test/unit/CMakeLists.txt +++ b/test/unit/CMakeLists.txt @@ -2,7 +2,7 @@ # Copyright (c) 2006-2021, Knut Reinert & Freie Universität Berlin # Copyright (c) 2016-2021, Knut Reinert & MPI für molekulare Genetik # This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License -# shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md +# shipped with this file and also available at: https://github.com/seqan/sharg-parser/blob/master/LICENSE.md # ----------------------------------------------------------------------------------------------------- cmake_minimum_required (VERSION 3.10) diff --git a/test/unit/argument_parser_design_error_test.cpp b/test/unit/argument_parser_design_error_test.cpp index 7ca7ab0f..65750235 100644 --- a/test/unit/argument_parser_design_error_test.cpp +++ b/test/unit/argument_parser_design_error_test.cpp @@ -2,7 +2,7 @@ // Copyright (c) 2006-2021, Knut Reinert & Freie Universität Berlin // Copyright (c) 2016-2021, Knut Reinert & MPI für molekulare Genetik // This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License -// shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md +// shipped with this file and also available at: https://github.com/seqan/sharg-parser/blob/master/LICENSE.md // ----------------------------------------------------------------------------------------------------- #include @@ -13,13 +13,13 @@ TEST(design_error, app_name_validation) { const char * argv[] = {"./argument_parser_test"}; - EXPECT_NO_THROW((seqan3::argument_parser{"test_parser", 1, argv})); - EXPECT_NO_THROW((seqan3::argument_parser{"test-parser1234_foo", 1, argv})); + EXPECT_NO_THROW((sharg::argument_parser{"test_parser", 1, argv})); + EXPECT_NO_THROW((sharg::argument_parser{"test-parser1234_foo", 1, argv})); - EXPECT_THROW((seqan3::argument_parser{"test parser", 1, argv}), seqan3::design_error); - EXPECT_THROW((seqan3::argument_parser{"test;", 1, argv}), seqan3::design_error); - EXPECT_THROW((seqan3::argument_parser{";", 1, argv}), seqan3::design_error); - EXPECT_THROW((seqan3::argument_parser{"test;bad script:D", 1, argv}), seqan3::design_error); + EXPECT_THROW((sharg::argument_parser{"test parser", 1, argv}), sharg::design_error); + EXPECT_THROW((sharg::argument_parser{"test;", 1, argv}), sharg::design_error); + EXPECT_THROW((sharg::argument_parser{";", 1, argv}), sharg::design_error); + EXPECT_THROW((sharg::argument_parser{"test;bad script:D", 1, argv}), sharg::design_error); } TEST(parse_test, design_error) @@ -28,74 +28,74 @@ TEST(parse_test, design_error) // short option const char * argv[] = {"./argument_parser_test"}; - seqan3::argument_parser parser{"test_parser", 1, argv}; + sharg::argument_parser parser{"test_parser", 1, argv}; parser.add_option(option_value, 'i', "int", "this is a int option."); EXPECT_THROW(parser.add_option(option_value, 'i', "aint", "oh oh same id."), - seqan3::design_error); + sharg::design_error); // long option - seqan3::argument_parser parser2{"test_parser", 1, argv}; + sharg::argument_parser parser2{"test_parser", 1, argv}; parser2.add_option(option_value, 'i', "int", "this is an int option."); EXPECT_THROW(parser2.add_option(option_value, 'a', "int", "oh oh another id."), - seqan3::design_error); + sharg::design_error); // empty identifier - seqan3::argument_parser parser3{"test_parser", 1, argv}; + sharg::argument_parser parser3{"test_parser", 1, argv}; EXPECT_THROW(parser3.add_option(option_value, '\0', "", "oh oh all is empty."), - seqan3::design_error); + sharg::design_error); bool flag_value; // short flag - seqan3::argument_parser parser4{"test_parser", 1, argv}; + sharg::argument_parser parser4{"test_parser", 1, argv}; parser4.add_flag(flag_value, 'i', "int1", "this is an int option."); EXPECT_THROW(parser4.add_flag(flag_value, 'i', "int2", "oh oh another id."), - seqan3::design_error); + sharg::design_error); // long flag - seqan3::argument_parser parser5{"test_parser", 1, argv}; + sharg::argument_parser parser5{"test_parser", 1, argv}; parser5.add_flag(flag_value, 'i', "int", "this is an int option."); EXPECT_THROW(parser5.add_flag(flag_value, 'a', "int", "oh oh another id."), - seqan3::design_error); + sharg::design_error); // empty identifier - seqan3::argument_parser parser6{"test_parser", 1, argv}; + sharg::argument_parser parser6{"test_parser", 1, argv}; EXPECT_THROW(parser6.add_flag(flag_value, '\0', "", "oh oh another id."), - seqan3::design_error); + sharg::design_error); // positional option not at the end const char * argv2[] = {"./argument_parser_test", "arg1", "arg2", "arg3"}; std::vector vec; - seqan3::argument_parser parser7{"test_parser", 4, argv2}; + sharg::argument_parser parser7{"test_parser", 4, argv2}; parser7.add_positional_option(vec, "oh oh list not at the end."); - EXPECT_THROW(parser7.add_positional_option(option_value, "desc."), seqan3::design_error); + EXPECT_THROW(parser7.add_positional_option(option_value, "desc."), sharg::design_error); // using h, help, advanced-help, and export-help - seqan3::argument_parser parser8{"test_parser", 1, argv}; + sharg::argument_parser parser8{"test_parser", 1, argv}; EXPECT_THROW(parser8.add_option(option_value, 'h', "", "-h is bad."), - seqan3::design_error); + sharg::design_error); EXPECT_THROW(parser8.add_option(option_value, '\0', "help", "help is bad."), - seqan3::design_error); + sharg::design_error); EXPECT_THROW(parser8.add_option(option_value, '\0', "advanced-help", - "advanced-help is bad"), seqan3::design_error); + "advanced-help is bad"), sharg::design_error); EXPECT_THROW(parser8.add_option(option_value, '\0', "export-help", - "export-help is bad"), seqan3::design_error); + "export-help is bad"), sharg::design_error); // using one-letter long identifiers. - seqan3::argument_parser parser9{"test_parser", 1, argv}; + sharg::argument_parser parser9{"test_parser", 1, argv}; EXPECT_THROW(parser9.add_option(option_value, 'y', "z", "long identifier is one letter"), - seqan3::design_error); + sharg::design_error); EXPECT_THROW(parser9.add_flag(flag_value, 'y', "z", "long identifier is one letter"), - seqan3::design_error); + sharg::design_error); // using non-printable characters - seqan3::argument_parser parser10{"test_parser", 1, argv}; + sharg::argument_parser parser10{"test_parser", 1, argv}; EXPECT_THROW(parser10.add_option(option_value, '\t', "no\n", "tab and newline don't work!"), - seqan3::design_error); + sharg::design_error); EXPECT_THROW(parser10.add_flag(flag_value, 'i', "no\n", "tab and newline don't work!"), - seqan3::design_error); + sharg::design_error); EXPECT_THROW(parser10.add_flag(flag_value, 'a', "-no", "can't start long_id with a hyphen"), - seqan3::design_error); + sharg::design_error); } TEST(parse_test, parse_called_twice) @@ -103,7 +103,7 @@ TEST(parse_test, parse_called_twice) std::string option_value; const char * argv[] = {"./argument_parser_test", "--version-check", "false", "-s", "option_string"}; - seqan3::argument_parser parser{"test_parser", 5, argv}; + sharg::argument_parser parser{"test_parser", 5, argv}; parser.add_option(option_value, 's', "string-option", "this is a string option."); testing::internal::CaptureStderr(); @@ -111,7 +111,7 @@ TEST(parse_test, parse_called_twice) EXPECT_TRUE((testing::internal::GetCapturedStderr()).empty()); EXPECT_EQ(option_value, "option_string"); - EXPECT_THROW(parser.parse(), seqan3::design_error); + EXPECT_THROW(parser.parse(), sharg::design_error); } TEST(parse_test, subcommand_argument_parser_error) @@ -121,31 +121,31 @@ TEST(parse_test, subcommand_argument_parser_error) // subcommand parsing was not enabled on construction but get_sub_parser() is called { const char * argv[]{"./top_level", "-f"}; - seqan3::argument_parser top_level_parser{"top_level", 2, argv, seqan3::update_notifications::off}; + sharg::argument_parser top_level_parser{"top_level", 2, argv, sharg::update_notifications::off}; top_level_parser.add_flag(flag_value, 'f', "foo", "foo bar"); EXPECT_NO_THROW(top_level_parser.parse()); EXPECT_EQ(true, flag_value); - EXPECT_THROW(top_level_parser.get_sub_parser(), seqan3::design_error); + EXPECT_THROW(top_level_parser.get_sub_parser(), sharg::design_error); } // subcommand key word must only contain alpha numeric characters { const char * argv[]{"./top_level", "-f"}; - EXPECT_THROW((seqan3::argument_parser{"top_level", + EXPECT_THROW((sharg::argument_parser{"top_level", 2, argv, - seqan3::update_notifications::off, - {"with space"}}), seqan3::design_error); + sharg::update_notifications::off, + {"with space"}}), sharg::design_error); } // no positional/options are allowed { const char * argv[]{"./top_level", "foo"}; - seqan3::argument_parser top_level_parser{"top_level", 2, argv, seqan3::update_notifications::off, {"foo"}}; + sharg::argument_parser top_level_parser{"top_level", 2, argv, sharg::update_notifications::off, {"foo"}}; - EXPECT_THROW((top_level_parser.add_option(flag_value, 'f', "foo", "foo bar")), seqan3::design_error); - EXPECT_THROW((top_level_parser.add_positional_option(flag_value, "foo bar")), seqan3::design_error); + EXPECT_THROW((top_level_parser.add_option(flag_value, 'f', "foo", "foo bar")), sharg::design_error); + EXPECT_THROW((top_level_parser.add_positional_option(flag_value, "foo bar")), sharg::design_error); } } diff --git a/test/unit/detail/format_help_test.cpp b/test/unit/detail/format_help_test.cpp index 4db846db..d2e36146 100644 --- a/test/unit/detail/format_help_test.cpp +++ b/test/unit/detail/format_help_test.cpp @@ -2,7 +2,7 @@ // Copyright (c) 2006-2021, Knut Reinert & Freie Universität Berlin // Copyright (c) 2016-2021, Knut Reinert & MPI für molekulare Genetik // This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License -// shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md +// shipped with this file and also available at: https://github.com/seqan/sharg-parser/blob/master/LICENSE.md // ----------------------------------------------------------------------------------------------------- #include @@ -43,7 +43,7 @@ std::string const basic_options_str = "OPTIONS\n" std::string const basic_version_str = "VERSION\n" " Last update:\n" " test_parser version:\n" - " SeqAn version: " + std::string{seqan3::seqan3_version_cstring} + "\n"; + " SeqAn version: " + std::string{sharg::sharg_version_cstring} + "\n"; std::string license_text() { @@ -63,12 +63,12 @@ namespace seqan3::detail { struct test_accessor { - static void set_terminal_width(seqan3::argument_parser & parser, unsigned terminal_width) + static void set_terminal_width(sharg::argument_parser & parser, unsigned terminal_width) { std::visit([terminal_width](auto & f) { - if constexpr(std::is_same_v) - f.layout = seqan3::detail::format_help::console_layout_struct{terminal_width}; + if constexpr(std::is_same_v) + f.layout = sharg::detail::format_help::console_layout_struct{terminal_width}; }, parser.format); } }; @@ -78,8 +78,8 @@ using seqan3::detail::test_accessor; TEST(help_page_printing, short_help) { - // Empty call with no options given. For seqan3::detail::format_short_help - seqan3::argument_parser parser0{"empty_options", 1, argv0}; + // Empty call with no options given. For sharg::detail::format_short_help + sharg::argument_parser parser0{"empty_options", 1, argv0}; test_accessor::set_terminal_width(parser0, 80); parser0.info.synopsis.push_back("./some_binary_name synopsis"); testing::internal::CaptureStdout(); @@ -96,7 +96,7 @@ TEST(help_page_printing, short_help) TEST(help_page_printing, no_information) { // Empty help call with -h - seqan3::argument_parser parser1{"test_parser", 2, argv1}; + sharg::argument_parser parser1{"test_parser", 2, argv1}; test_accessor::set_terminal_width(parser1, 80); testing::internal::CaptureStdout(); EXPECT_EXIT(parser1.parse(), ::testing::ExitedWithCode(EXIT_SUCCESS), ""); @@ -113,7 +113,7 @@ TEST(help_page_printing, no_information) TEST(help_page_printing, with_short_copyright) { // Again, but with short copyright, long copyright, and citation. - seqan3::argument_parser short_copy("test_parser", 2, argv1); + sharg::argument_parser short_copy("test_parser", 2, argv1); test_accessor::set_terminal_width(short_copy, 80); short_copy.info.short_copyright = "short"; testing::internal::CaptureStdout(); @@ -135,7 +135,7 @@ TEST(help_page_printing, with_short_copyright) TEST(help_page_printing, with_long_copyright) { - seqan3::argument_parser long_copy("test_parser", 2, argv1); + sharg::argument_parser long_copy("test_parser", 2, argv1); test_accessor::set_terminal_width(long_copy, 80); long_copy.info.long_copyright = "long"; testing::internal::CaptureStdout(); @@ -157,7 +157,7 @@ TEST(help_page_printing, with_long_copyright) TEST(help_page_printing, with_citation) { - seqan3::argument_parser citation("test_parser", 2, argv1); + sharg::argument_parser citation("test_parser", 2, argv1); test_accessor::set_terminal_width(citation, 80); citation.info.citation = "citation"; testing::internal::CaptureStdout(); @@ -179,7 +179,7 @@ TEST(help_page_printing, with_citation) TEST(help_page_printing, with_author) { - seqan3::argument_parser author("test_parser", 2, argv1); + sharg::argument_parser author("test_parser", 2, argv1); test_accessor::set_terminal_width(author, 80); author.info.author = "author"; testing::internal::CaptureStdout(); @@ -201,7 +201,7 @@ TEST(help_page_printing, with_author) TEST(help_page_printing, with_email) { - seqan3::argument_parser email("test_parser", 2, argv1); + sharg::argument_parser email("test_parser", 2, argv1); test_accessor::set_terminal_width(email, 80); email.info.email = "email"; testing::internal::CaptureStdout(); @@ -224,7 +224,7 @@ TEST(help_page_printing, with_email) TEST(help_page_printing, empty_advanced_help) { // Empty help call with -hh - seqan3::argument_parser parser2{"test_parser", 2, argv2}; + sharg::argument_parser parser2{"test_parser", 2, argv2}; test_accessor::set_terminal_width(parser2, 80); testing::internal::CaptureStdout(); EXPECT_EXIT(parser2.parse(), ::testing::ExitedWithCode(EXIT_SUCCESS), ""); @@ -241,7 +241,7 @@ TEST(help_page_printing, empty_advanced_help) TEST(help_page_printing, empty_version_call) { // Empty version call - seqan3::argument_parser parser3{"test_parser", 2, argv3}; + sharg::argument_parser parser3{"test_parser", 2, argv3}; test_accessor::set_terminal_width(parser3, 80); testing::internal::CaptureStdout(); EXPECT_EXIT(parser3.parse(), ::testing::ExitedWithCode(EXIT_SUCCESS), ""); @@ -256,7 +256,7 @@ TEST(help_page_printing, empty_version_call) TEST(help_page_printing, version_call) { // Version call with url and options. - seqan3::argument_parser parser4{"test_parser", 2, argv3}; + sharg::argument_parser parser4{"test_parser", 2, argv3}; test_accessor::set_terminal_width(parser4, 80); parser4.info.url = "https://seqan.de"; parser4.add_option(option_value, 'i', "int", "this is a int option."); @@ -278,10 +278,10 @@ TEST(help_page_printing, version_call) TEST(help_page_printing, do_not_print_hidden_options) { // Add an option and request help. - seqan3::argument_parser parser5{"test_parser", 2, argv1}; + sharg::argument_parser parser5{"test_parser", 2, argv1}; test_accessor::set_terminal_width(parser5, 80); - parser5.add_option(option_value, 'i', "int", "this is a int option.", seqan3::option_spec::hidden); - parser5.add_flag(flag_value, 'f', "flag", "this is a flag.", seqan3::option_spec::hidden); + parser5.add_option(option_value, 'i', "int", "this is a int option.", sharg::option_spec::hidden); + parser5.add_flag(flag_value, 'f', "flag", "this is a flag.", sharg::option_spec::hidden); testing::internal::CaptureStdout(); EXPECT_EXIT(parser5.parse(), ::testing::ExitedWithCode(EXIT_SUCCESS), ""); std_cout = testing::internal::GetCapturedStdout(); @@ -299,35 +299,35 @@ TEST(help_page_printing, advanced_options) int32_t option_value{5}; bool flag_value{}; - auto set_up = [&option_value, &flag_value] (seqan3::argument_parser & parser) + auto set_up = [&option_value, &flag_value] (sharg::argument_parser & parser) { // default or required information are always displayed - parser.add_section("default section", seqan3::option_spec::required); - parser.add_subsection("default subsection", seqan3::option_spec::required); // same as DEFAULT - parser.add_option(option_value, 'i', "int", "this is a int option.", seqan3::option_spec::required); - parser.add_flag(flag_value, 'g', "goo", "this is a flag.", seqan3::option_spec::required); // same as DEFAULT - parser.add_list_item("-s, --some", "list item.", seqan3::option_spec::required); // same as DEFAULT - parser.add_line("some line.", true, seqan3::option_spec::required); // same as DEFAULT + parser.add_section("default section", sharg::option_spec::required); + parser.add_subsection("default subsection", sharg::option_spec::required); // same as DEFAULT + parser.add_option(option_value, 'i', "int", "this is a int option.", sharg::option_spec::required); + parser.add_flag(flag_value, 'g', "goo", "this is a flag.", sharg::option_spec::required); // same as DEFAULT + parser.add_list_item("-s, --some", "list item.", sharg::option_spec::required); // same as DEFAULT + parser.add_line("some line.", true, sharg::option_spec::required); // same as DEFAULT // advanced information - parser.add_section("advanced section", seqan3::option_spec::advanced); - parser.add_subsection("advanced subsection", seqan3::option_spec::advanced); - parser.add_option(option_value, 'j', "jnt", "this is a int option.", seqan3::option_spec::advanced); - parser.add_flag(flag_value, 'f', "flag", "this is a flag.", seqan3::option_spec::advanced); - parser.add_list_item("-s, --some", "list item.", seqan3::option_spec::advanced); - parser.add_line("some line.", true, seqan3::option_spec::advanced); + parser.add_section("advanced section", sharg::option_spec::advanced); + parser.add_subsection("advanced subsection", sharg::option_spec::advanced); + parser.add_option(option_value, 'j', "jnt", "this is a int option.", sharg::option_spec::advanced); + parser.add_flag(flag_value, 'f', "flag", "this is a flag.", sharg::option_spec::advanced); + parser.add_list_item("-s, --some", "list item.", sharg::option_spec::advanced); + parser.add_line("some line.", true, sharg::option_spec::advanced); // hidden information (never displayed, normally used for options not section information) - parser.add_section("hidden section", seqan3::option_spec::hidden); - parser.add_subsection("hidden subsection", seqan3::option_spec::hidden); - parser.add_option(option_value, 'd', "dnt", "hidden option.", seqan3::option_spec::hidden); - parser.add_flag(flag_value, 'l', "lflag", "hidden a flag.", seqan3::option_spec::hidden); - parser.add_list_item("-s, --some", "hidden list item.", seqan3::option_spec::hidden); - parser.add_line("hidden line.", true, seqan3::option_spec::hidden); + parser.add_section("hidden section", sharg::option_spec::hidden); + parser.add_subsection("hidden subsection", sharg::option_spec::hidden); + parser.add_option(option_value, 'd', "dnt", "hidden option.", sharg::option_spec::hidden); + parser.add_flag(flag_value, 'l', "lflag", "hidden a flag.", sharg::option_spec::hidden); + parser.add_list_item("-s, --some", "hidden list item.", sharg::option_spec::hidden); + parser.add_line("hidden line.", true, sharg::option_spec::hidden); }; // without -hh, only the non/advanced information are shown - seqan3::argument_parser parser_normal_help{"test_parser", 2, argv1}; + sharg::argument_parser parser_normal_help{"test_parser", 2, argv1}; test_accessor::set_terminal_width(parser_normal_help, 80); set_up(parser_normal_help); testing::internal::CaptureStdout(); @@ -353,7 +353,7 @@ TEST(help_page_printing, advanced_options) EXPECT_EQ(std_cout, expected); // with -hh everything is shown - seqan3::argument_parser parser_advanced_help{"test_parser", 2, argv2}; + sharg::argument_parser parser_advanced_help{"test_parser", 2, argv2}; test_accessor::set_terminal_width(parser_advanced_help, 80); set_up(parser_advanced_help); testing::internal::CaptureStdout(); @@ -409,7 +409,7 @@ TEST(help_page_printing, full_information) foo enum_option_value{}; // Add synopsis, description, short description, positional option, option, flag, and example. - seqan3::argument_parser parser6{"test_parser", 2, argv1}; + sharg::argument_parser parser6{"test_parser", 2, argv1}; test_accessor::set_terminal_width(parser6, 80); parser6.info.synopsis.push_back("./some_binary_name synopsis"); parser6.info.synopsis.push_back("./some_binary_name synopsis2"); @@ -417,10 +417,10 @@ TEST(help_page_printing, full_information) parser6.info.description.push_back("description2"); parser6.info.short_description = "so short"; parser6.add_option(option_value, 'i', "int", "this is a int option."); - parser6.add_option(enum_option_value, 'e', "enum", "this is an enum option.", seqan3::option_spec::standard, - seqan3::value_list_validator{seqan3::enumeration_names | std::views::values}); + parser6.add_option(enum_option_value, 'e', "enum", "this is an enum option.", sharg::option_spec::standard, + sharg::value_list_validator{sharg::enumeration_names | std::views::values}); parser6.add_option(required_option, 'r', "required-int", "this is another int option.", - seqan3::option_spec::required); + sharg::option_spec::required); parser6.add_section("Flags"); parser6.add_subsection("SubFlags"); parser6.add_line("here come all the flags"); @@ -479,7 +479,7 @@ TEST(help_page_printing, copyright) { // Tests the --copyright call. const char * argvCopyright[] = {"./copyright", "--copyright"}; - seqan3::argument_parser copyright("myApp", 2, argvCopyright); + sharg::argument_parser copyright("myApp", 2, argvCopyright); std::string license_string = license_text(); @@ -549,10 +549,10 @@ TEST(parse_test, subcommand_argument_parser) std::string option_value2{}; const char * argv[]{"./test_parser", "-h"}; - seqan3::argument_parser top_level_parser{"test_parser", + sharg::argument_parser top_level_parser{"test_parser", 2, argv, - seqan3::update_notifications::on, + sharg::update_notifications::on, {"sub1", "sub2"}}; test_accessor::set_terminal_width(top_level_parser, 80); top_level_parser.info.description.push_back("description"); diff --git a/test/unit/detail/format_html_test.cpp b/test/unit/detail/format_html_test.cpp index 8c045809..8bfeaa41 100644 --- a/test/unit/detail/format_html_test.cpp +++ b/test/unit/detail/format_html_test.cpp @@ -2,7 +2,7 @@ // Copyright (c) 2006-2021, Knut Reinert & Freie Universität Berlin // Copyright (c) 2016-2021, Knut Reinert & MPI für molekulare Genetik // This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License -// shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md +// shipped with this file and also available at: https://github.com/seqan/sharg-parser/blob/master/LICENSE.md // ----------------------------------------------------------------------------------------------------- #include @@ -18,7 +18,7 @@ TEST(html_format, empty_information) // Empty html help page. const char * argv0[] = {"./help_add_test --version-check false", "--export-help", "html"}; - seqan3::argument_parser parser0{"empty_options", 3, argv0}; + sharg::argument_parser parser0{"empty_options", 3, argv0}; testing::internal::CaptureStdout(); EXPECT_EXIT(parser0.parse(), ::testing::ExitedWithCode(EXIT_SUCCESS), ""); my_stdout = testing::internal::GetCapturedStdout(); @@ -53,14 +53,14 @@ TEST(html_format, empty_information) "
\n" "empty_options version: \n" "
\n" - "SeqAn version: " + std::string{seqan3::seqan3_version_cstring} + "\n" + "SeqAn version: " + std::string{sharg::sharg_version_cstring} + "\n" "
\n" "

\n" ""); EXPECT_EQ(my_stdout, expected); const char * argv1[] = {"./help_add_test --version-check false", "--export-help=html"}; - seqan3::argument_parser parser1{"empty_options", 2, argv1}; + sharg::argument_parser parser1{"empty_options", 2, argv1}; testing::internal::CaptureStdout(); EXPECT_EXIT(parser1.parse(), ::testing::ExitedWithCode(EXIT_SUCCESS), ""); my_stdout = testing::internal::GetCapturedStdout(); @@ -78,7 +78,7 @@ TEST(html_format, full_information_information) // Full html help page. const char * argv0[] = {"./help_add_test --version-check false", "--export-help", "html"}; - seqan3::argument_parser parser1{"program_full_options", 3, argv0}; + sharg::argument_parser parser1{"program_full_options", 3, argv0}; parser1.info.synopsis.push_back("./some_binary_name synopsis"); parser1.info.synopsis.push_back("./some_binary_name synopsis2"); parser1.info.description.push_back("description"); @@ -91,7 +91,7 @@ TEST(html_format, full_information_information) parser1.info.author = "author"; parser1.info.email = "email"; parser1.add_option(option_value, 'i', "int", "this is a int option."); - parser1.add_option(option_value, 'j', "jint", "this is a required int option.", seqan3::option_spec::required); + parser1.add_option(option_value, 'j', "jint", "this is a required int option.", sharg::option_spec::required); parser1.add_flag(flag_value, 'f', "flag", "this is a flag."); parser1.add_flag(flag_value, 'k', "kflag", "this is a flag."); parser1.add_positional_option(non_list_pos_opt_value, "this is a positional option."); @@ -169,7 +169,7 @@ TEST(html_format, full_information_information) "
\n" "program_full_options version: \n" "
\n" - "SeqAn version: " + std::string{seqan3::seqan3_version_cstring} + "\n" + "SeqAn version: " + std::string{sharg::sharg_version_cstring} + "\n" "
\n" "

\n" "

Url

\n" @@ -203,11 +203,11 @@ TEST(export_help, parse_error) const char * argv3[] = {"./help_add_test --version-check false", "--export-help", "atml"}; // no value after --export-help - EXPECT_THROW((seqan3::argument_parser{"test_parser", 2, argv}), seqan3::argument_parser_error); + EXPECT_THROW((sharg::argument_parser{"test_parser", 2, argv}), sharg::argument_parser_error); // wrong value after --export-help - EXPECT_THROW((seqan3::argument_parser{"test_parser", 2, argv2}), seqan3::validation_error); + EXPECT_THROW((sharg::argument_parser{"test_parser", 2, argv2}), sharg::validation_error); // wrong value after --export-help - EXPECT_THROW((seqan3::argument_parser{"test_parser", 3, argv3}), seqan3::validation_error); + EXPECT_THROW((sharg::argument_parser{"test_parser", 3, argv3}), sharg::validation_error); } diff --git a/test/unit/detail/format_man_test.cpp b/test/unit/detail/format_man_test.cpp index 57a63c42..30c3baf9 100644 --- a/test/unit/detail/format_man_test.cpp +++ b/test/unit/detail/format_man_test.cpp @@ -2,7 +2,7 @@ // Copyright (c) 2006-2021, Knut Reinert & Freie Universität Berlin // Copyright (c) 2016-2021, Knut Reinert & MPI für molekulare Genetik // This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License -// shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md +// shipped with this file and also available at: https://github.com/seqan/sharg-parser/blob/master/LICENSE.md // ----------------------------------------------------------------------------------------------------- #include @@ -22,7 +22,7 @@ struct format_man_test : public ::testing::Test std::vector list_pos_opt_value{}; std::string my_stdout{}; const char * argv[4] = {"./format_man_test --version-check false", "--export-help", "man"}; - std::string const version_str{seqan3::seqan3_version_cstring}; + std::string const version_str{sharg::sharg_version_cstring}; std::string expected = R"(.TH DEFAULT 1 "December 01, 1994" "default 01.01.01" "default_man_page_title")" "\n" R"(.SH NAME)" "\n" @@ -89,7 +89,7 @@ struct format_man_test : public ::testing::Test R"(\fBSeqAn version: \fR)" + version_str + "\n"; // Full info parser initialisation - void dummy_init(seqan3::argument_parser & parser) + void dummy_init(sharg::argument_parser & parser) { parser.info.date = "December 01, 1994"; parser.info.version = "01.01.01"; @@ -100,7 +100,7 @@ struct format_man_test : public ::testing::Test parser.info.description.push_back("description"); parser.info.description.push_back("description2"); parser.add_option(option_value, 'i', "int", "this is a int option."); - parser.add_option(option_value, 'j', "jint", "this is a required int option.", seqan3::option_spec::required); + parser.add_option(option_value, 'j', "jint", "this is a required int option.", sharg::option_spec::required); parser.add_section("Flags"); parser.add_subsection("SubFlags"); parser.add_line("here come all the flags"); @@ -116,13 +116,13 @@ struct format_man_test : public ::testing::Test TEST_F(format_man_test, empty_information) { // Create the dummy parser. - seqan3::argument_parser parser{"default", 3, argv}; + sharg::argument_parser parser{"default", 3, argv}; parser.info.date = "December 01, 1994"; parser.info.version = "01.01.01"; parser.info.man_page_title = "default_man_page_title"; parser.info.short_description = "A short description here."; - std::string const version_str{seqan3::seqan3_version_cstring}; + std::string const version_str{sharg::sharg_version_cstring}; std::string expected_short = R"(.TH DEFAULT 1 "December 01, 1994" "default 01.01.01" "default_man_page_title")" "\n" R"(.SH NAME)" "\n" @@ -165,7 +165,7 @@ TEST_F(format_man_test, empty_information) TEST_F(format_man_test, full_information) { // Create the dummy parser. - seqan3::argument_parser parser{"default", 3, argv}; + sharg::argument_parser parser{"default", 3, argv}; // Fill out the dummy parser with options and flags and sections and subsections. dummy_init(parser); @@ -180,7 +180,7 @@ TEST_F(format_man_test, full_information) TEST_F(format_man_test, full_info_short_copyright) { // Create the dummy parser. - seqan3::argument_parser parser{"default", 3, argv}; + sharg::argument_parser parser{"default", 3, argv}; // Fill out the dummy parser with options and flags and sections and subsections. dummy_init(parser); @@ -201,7 +201,7 @@ TEST_F(format_man_test, full_info_short_copyright) TEST_F(format_man_test, full_info_short_and_citation) { // Create the dummy parser. - seqan3::argument_parser parser{"default", 3, argv}; + sharg::argument_parser parser{"default", 3, argv}; // Fill out the dummy parser with options and flags and sections and subsections. dummy_init(parser); @@ -225,7 +225,7 @@ TEST_F(format_man_test, full_info_short_and_citation) TEST_F(format_man_test, full_info_short_long_and_citation) { // Create the dummy parser. - seqan3::argument_parser parser{"default", 3, argv}; + sharg::argument_parser parser{"default", 3, argv}; // Fill out the dummy parser with options and flags and sections and subsections. dummy_init(parser); @@ -252,7 +252,7 @@ For full copyright and/or warranty information see \fB--copyright\fR. TEST_F(format_man_test, full_info_author) { // Create the dummy parser. - seqan3::argument_parser parser{"default", 3, argv}; + sharg::argument_parser parser{"default", 3, argv}; // Fill out the dummy parser with options and flags and sections and subsections. dummy_init(parser); @@ -273,7 +273,7 @@ TEST_F(format_man_test, full_info_author) TEST_F(format_man_test, full_info_email) { // Create the dummy parser. - seqan3::argument_parser parser{"default", 3, argv}; + sharg::argument_parser parser{"default", 3, argv}; // Fill out the dummy parser with options and flags and sections and subsections. dummy_init(parser); diff --git a/test/unit/detail/version_check_debug_test.cpp b/test/unit/detail/version_check_debug_test.cpp index c0be5923..87959641 100644 --- a/test/unit/detail/version_check_debug_test.cpp +++ b/test/unit/detail/version_check_debug_test.cpp @@ -2,7 +2,7 @@ // Copyright (c) 2006-2021, Knut Reinert & Freie Universität Berlin // Copyright (c) 2016-2021, Knut Reinert & MPI für molekulare Genetik // This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License -// shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md +// shipped with this file and also available at: https://github.com/seqan/sharg-parser/blob/master/LICENSE.md // ----------------------------------------------------------------------------------------------------- #if defined(NDEBUG) diff --git a/test/unit/detail/version_check_release_test.cpp b/test/unit/detail/version_check_release_test.cpp index 7af9380f..977760b3 100644 --- a/test/unit/detail/version_check_release_test.cpp +++ b/test/unit/detail/version_check_release_test.cpp @@ -2,7 +2,7 @@ // Copyright (c) 2006-2021, Knut Reinert & Freie Universität Berlin // Copyright (c) 2016-2021, Knut Reinert & MPI für molekulare Genetik // This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License -// shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md +// shipped with this file and also available at: https://github.com/seqan/sharg-parser/blob/master/LICENSE.md // ----------------------------------------------------------------------------------------------------- #if !defined(NDEBUG) diff --git a/test/unit/detail/version_check_test.hpp b/test/unit/detail/version_check_test.hpp index b0402c50..cac2d116 100644 --- a/test/unit/detail/version_check_test.hpp +++ b/test/unit/detail/version_check_test.hpp @@ -2,7 +2,7 @@ // Copyright (c) 2006-2021, Knut Reinert & Freie Universität Berlin // Copyright (c) 2016-2021, Knut Reinert & MPI für molekulare Genetik // This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License -// shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md +// shipped with this file and also available at: https://github.com/seqan/sharg-parser/blob/master/LICENSE.md // ----------------------------------------------------------------------------------------------------- #include @@ -23,14 +23,14 @@ namespace seqan3::detail { struct test_accessor { - static auto & version_check_future(seqan3::argument_parser & parser) + static auto & version_check_future(sharg::argument_parser & parser) { return parser.version_check_future; } }; } // seqan3::detail -bool wait_for(seqan3::argument_parser & parser) +bool wait_for(sharg::argument_parser & parser) { auto & future = seqan3::detail::test_accessor::version_check_future(parser); @@ -55,10 +55,10 @@ struct version_check : public ::testing::Test using namespace std::string_literals; auto tmp_directory = tmp_file.get_path().parent_path(); - int result = setenv(seqan3::detail::version_checker::home_env_name, tmp_directory.c_str(), 1); + int result = setenv(sharg::detail::version_checker::home_env_name, tmp_directory.c_str(), 1); if (result != 0) throw std::runtime_error{"Couldn't set environment variable 'home_env_name' (="s + - seqan3::detail::version_checker::home_env_name + ")"s}; + sharg::detail::version_checker::home_env_name + ")"s}; auto is_prefix_path = [](std::string const & base_path, std::string const & path) { @@ -82,7 +82,7 @@ struct version_check : public ::testing::Test std::filesystem::path app_tmp_path() { - return seqan3::detail::version_checker::get_path(); + return sharg::detail::version_checker::get_path(); } std::filesystem::path app_version_filename() @@ -92,7 +92,7 @@ struct version_check : public ::testing::Test std::filesystem::path app_timestamp_filename() { - return seqan3::detail::version_checker{app_name, std::string{}}.timestamp_filename; + return sharg::detail::version_checker{app_name, std::string{}}.timestamp_filename; } std::chrono::duration::rep current_unix_timestamp() @@ -107,15 +107,15 @@ struct version_check : public ::testing::Test { // make sure that the environment variable is not set std::string previous_value{}; - if (char * env = std::getenv("SEQAN3_NO_VERSION_CHECK")) + if (char * env = std::getenv("SHARG_NO_VERSION_CHECK")) { previous_value = env; - unsetenv("SEQAN3_NO_VERSION_CHECK"); + unsetenv("SHARG_NO_VERSION_CHECK"); } bool app_call_succeeded{false}; - seqan3::argument_parser parser{app_name, argc, argv}; + sharg::argument_parser parser{app_name, argc, argv}; parser.info.version = "2.3.4"; // In case we don't want to specify --version-check but avoid that short help format will be set (no arguments) @@ -133,7 +133,7 @@ struct version_check : public ::testing::Test app_call_succeeded = wait_for(parser); if (!previous_value.empty()) - setenv("SEQAN3_NO_VERSION_CHECK", previous_value.c_str(), 1); + setenv("SHARG_NO_VERSION_CHECK", previous_value.c_str(), 1); return {out, err, app_call_succeeded}; } @@ -228,7 +228,7 @@ TEST_F(version_check, option_on) } // Note that we cannot test interactiveness because google test captures std::cin and thus -// seqan3::detail::is_terminal() is always false +// sharg::detail::is_terminal() is always false TEST_F(version_check, option_implicitely_on) { const char * argv[2] = {app_name.c_str(), "-f"}; @@ -281,14 +281,14 @@ TEST_F(version_check, environment_variable_set) { // store variable for resetting it std::string previous_value{}; - if (char * env = std::getenv("SEQAN3_NO_VERSION_CHECK")) + if (char * env = std::getenv("SHARG_NO_VERSION_CHECK")) previous_value = env; - setenv("SEQAN3_NO_VERSION_CHECK", "foo", 1); + setenv("SHARG_NO_VERSION_CHECK", "foo", 1); const char * argv[2] = {app_name.c_str(), "-f"}; - seqan3::argument_parser parser{app_name, 2, argv}; + sharg::argument_parser parser{app_name, 2, argv}; parser.info.version = "2.3.4"; bool dummy{}; parser.add_flag(dummy, 'f', "dummy-flag", "A dummy flag."); @@ -311,9 +311,9 @@ TEST_F(version_check, environment_variable_set) EXPECT_FALSE(std::filesystem::exists(app_version_filename())); if (previous_value.empty()) - unsetenv("SEQAN3_NO_VERSION_CHECK"); + unsetenv("SHARG_NO_VERSION_CHECK"); else - setenv("SEQAN3_NO_VERSION_CHECK", previous_value.c_str(), 1); + setenv("SHARG_NO_VERSION_CHECK", previous_value.c_str(), 1); EXPECT_TRUE(remove_files_from_path()); // clear files again } @@ -337,13 +337,13 @@ TEST_F(version_check, option_off) const char * argv2[4] = {app_name.c_str(), "-h", OPTION_VERSION_CHECK, OPTION_OFF}; std::string previous_value{}; - if (char * env = std::getenv("SEQAN3_NO_VERSION_CHECK")) + if (char * env = std::getenv("SHARG_NO_VERSION_CHECK")) { previous_value = env; - unsetenv("SEQAN3_NO_VERSION_CHECK"); + unsetenv("SHARG_NO_VERSION_CHECK"); } - seqan3::argument_parser parser{app_name, 4, argv2}; + sharg::argument_parser parser{app_name, 4, argv2}; parser.info.version = "2.3.4"; EXPECT_EXIT(parser.parse(), ::testing::ExitedWithCode(EXIT_SUCCESS), ""); @@ -353,7 +353,7 @@ TEST_F(version_check, option_off) EXPECT_FALSE(wait_for(parser)); if (!previous_value.empty()) - setenv("SEQAN3_NO_VERSION_CHECK", previous_value.c_str(), 1); + setenv("SHARG_NO_VERSION_CHECK", previous_value.c_str(), 1); // no timestamp is written since the decision was made explicitly EXPECT_FALSE(std::filesystem::exists(app_version_filename())) << app_version_filename(); @@ -377,7 +377,7 @@ TEST_F(version_check, smaller_seqan3_version) (void) app_call_succeeded; EXPECT_EQ(out, ""); - EXPECT_EQ(err, seqan3::detail::version_checker::message_seqan3_update); + EXPECT_EQ(err, sharg::detail::version_checker::message_seqan3_update); EXPECT_TRUE(std::regex_match(read_file(app_timestamp_filename()), timestamp_regex)); @@ -390,7 +390,7 @@ TEST_F(version_check, greater_app_version) const char * argv[3] = {app_name.c_str(), OPTION_VERSION_CHECK, OPTION_ON}; // create version file with equal seqan version and a smaller app version than the current - ASSERT_TRUE(create_file(app_version_filename(), std::string{"1.5.9\n"} + seqan3::seqan3_version_cstring)); + ASSERT_TRUE(create_file(app_version_filename(), std::string{"1.5.9\n"} + sharg::sharg_version_cstring)); // create timestamp file that dates one day before current to trigger a message ASSERT_TRUE(create_file(app_timestamp_filename(), current_unix_timestamp() - 100401)); // one day = 86400 seconds @@ -399,7 +399,7 @@ TEST_F(version_check, greater_app_version) (void) app_call_succeeded; EXPECT_EQ(out, ""); - EXPECT_EQ(err, seqan3::detail::version_checker::message_registered_app_update); + EXPECT_EQ(err, sharg::detail::version_checker::message_registered_app_update); EXPECT_TRUE(std::regex_match(read_file(app_timestamp_filename()), timestamp_regex)); @@ -411,7 +411,7 @@ TEST_F(version_check, unregistered_app) const char * argv[3] = {app_name.c_str(), OPTION_VERSION_CHECK, OPTION_ON}; // create version file with equal seqan version and a smaller app version than the current - ASSERT_TRUE(create_file(app_version_filename(), std::string{"UNREGISTERED_APP\n"} + seqan3::seqan3_version_cstring)); + ASSERT_TRUE(create_file(app_version_filename(), std::string{"UNREGISTERED_APP\n"} + sharg::sharg_version_cstring)); // create timestamp file that dates one day before current to trigger a message ASSERT_TRUE(create_file(app_timestamp_filename(), current_unix_timestamp() - 100401)); // one day = 86400 seconds @@ -420,7 +420,7 @@ TEST_F(version_check, unregistered_app) (void) app_call_succeeded; EXPECT_EQ(out, ""); - EXPECT_EQ(err, seqan3::detail::version_checker::message_unregistered_app); + EXPECT_EQ(err, sharg::detail::version_checker::message_unregistered_app); EXPECT_TRUE(std::regex_match(read_file(app_timestamp_filename()), timestamp_regex)); @@ -435,7 +435,7 @@ TEST_F(version_check, smaller_app_version) const char * argv[3] = {app_name.c_str(), OPTION_VERSION_CHECK, OPTION_ON}; // create version file with equal seqan version and a greater app version than the current - ASSERT_TRUE(create_file(app_version_filename(), std::string{"20.5.9\n"} + seqan3::seqan3_version_cstring)); + ASSERT_TRUE(create_file(app_version_filename(), std::string{"20.5.9\n"} + sharg::sharg_version_cstring)); // create timestamp file that dates one day before current to trigger a message (one day = 86400 seconds) ASSERT_TRUE(create_file(app_timestamp_filename(), current_unix_timestamp() - 100401)); @@ -444,7 +444,7 @@ TEST_F(version_check, smaller_app_version) (void) app_call_succeeded; EXPECT_EQ(out, ""); - EXPECT_EQ(err, (seqan3::detail::version_checker{app_name, "2.3.4"}.message_app_update)); + EXPECT_EQ(err, (sharg::detail::version_checker{app_name, "2.3.4"}.message_app_update)); EXPECT_TRUE(std::regex_match(read_file(app_timestamp_filename()), timestamp_regex)); @@ -454,21 +454,21 @@ TEST_F(version_check, smaller_app_version) TEST_F(version_check, smaller_app_version_custom_url) { std::string previous_value{}; - if (char * env = std::getenv("SEQAN3_NO_VERSION_CHECK")) + if (char * env = std::getenv("SHARG_NO_VERSION_CHECK")) { previous_value = env; - unsetenv("SEQAN3_NO_VERSION_CHECK"); + unsetenv("SHARG_NO_VERSION_CHECK"); } const char * argv[3] = {app_name.c_str(), OPTION_VERSION_CHECK, OPTION_ON}; // create version file with equal seqan version and a greater app version than the current - ASSERT_TRUE(create_file(app_version_filename(), std::string{"20.5.9\n"} + seqan3::seqan3_version_cstring)); + ASSERT_TRUE(create_file(app_version_filename(), std::string{"20.5.9\n"} + sharg::sharg_version_cstring)); // create timestamp file that dates one day before current to trigger a message (one day = 86400 seconds) ASSERT_TRUE(create_file(app_timestamp_filename(), current_unix_timestamp() - 100401)); - seqan3::argument_parser parser{app_name, 3, argv}; + sharg::argument_parser parser{app_name, 3, argv}; parser.info.version = "2.3.4"; parser.info.url = "https//foo.de"; @@ -484,12 +484,12 @@ TEST_F(version_check, smaller_app_version_custom_url) EXPECT_EQ(out, ""); EXPECT_EQ(err, - (seqan3::detail::version_checker{app_name, parser.info.version, parser.info.url}.message_app_update)); + (sharg::detail::version_checker{app_name, parser.info.version, parser.info.url}.message_app_update)); EXPECT_TRUE(std::regex_match(read_file(app_timestamp_filename()), timestamp_regex)); if (!previous_value.empty()) - setenv("SEQAN3_NO_VERSION_CHECK", previous_value.c_str(), 1); + setenv("SHARG_NO_VERSION_CHECK", previous_value.c_str(), 1); EXPECT_TRUE(remove_files_from_path()); // clear files again } diff --git a/test/unit/format_parse_test.cpp b/test/unit/format_parse_test.cpp index 874abca2..bb372331 100644 --- a/test/unit/format_parse_test.cpp +++ b/test/unit/format_parse_test.cpp @@ -2,7 +2,7 @@ // Copyright (c) 2006-2021, Knut Reinert & Freie Universität Berlin // Copyright (c) 2016-2021, Knut Reinert & MPI für molekulare Genetik // This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License -// shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md +// shipped with this file and also available at: https://github.com/seqan/sharg-parser/blob/master/LICENSE.md // ----------------------------------------------------------------------------------------------------- #include @@ -14,7 +14,7 @@ TEST(parse_type_test, add_option_short_id) std::string option_value; const char * argv[] = {"./argument_parser_test", "-s", "option_string"}; - seqan3::argument_parser parser{"test_parser", 3, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 3, argv, sharg::update_notifications::off}; parser.add_section("My options"); // no-op for code coverage parser.add_subsection("My suboptions"); // no-op for code coverage parser.add_line("line"); // no-op for code coverage @@ -28,7 +28,7 @@ TEST(parse_type_test, add_option_short_id) // add with no space const char * argv2[] = {"./argument_parser_test", "-Soption_string"}; - seqan3::argument_parser parser2{"test_parser", 2, argv2, seqan3::update_notifications::off}; + sharg::argument_parser parser2{"test_parser", 2, argv2, sharg::update_notifications::off}; parser2.add_option(option_value, 'S', "string-option", "this is a string option."); testing::internal::CaptureStderr(); @@ -38,7 +38,7 @@ TEST(parse_type_test, add_option_short_id) // ad with = sign const char * argv3[] = {"./argument_parser_test", "-s=option_string"}; - seqan3::argument_parser parser3{"test_parser", 2, argv3, seqan3::update_notifications::off}; + sharg::argument_parser parser3{"test_parser", 2, argv3, sharg::update_notifications::off}; parser3.add_option(option_value, 's', "string-option", "this is a string option."); testing::internal::CaptureStderr(); @@ -52,7 +52,7 @@ TEST(parse_type_test, add_option_long_id) std::string option_value; const char * argv[] = {"./argument_parser_test", "--string-option", "option_string"}; - seqan3::argument_parser parser{"test_parser", 3, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 3, argv, sharg::update_notifications::off}; parser.add_option(option_value, 's', "string-option", "this is a string option."); testing::internal::CaptureStderr(); @@ -61,7 +61,7 @@ TEST(parse_type_test, add_option_long_id) EXPECT_EQ(option_value, "option_string"); const char * argv3[] = {"./argument_parser_test", "--string-option=option_string"}; - seqan3::argument_parser parser3{"test_parser", 2, argv3, seqan3::update_notifications::off}; + sharg::argument_parser parser3{"test_parser", 2, argv3, sharg::update_notifications::off}; parser3.add_option(option_value, 's', "string-option", "this is a string option."); testing::internal::CaptureStderr(); @@ -76,7 +76,7 @@ TEST(parse_type_test, add_flag_short_id_single) bool option_value2{true}; const char * argv[] = {"./argument_parser_test", "-t"}; - seqan3::argument_parser parser{"test_parser", 2, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 2, argv, sharg::update_notifications::off}; parser.add_flag(option_value1, 't', "true-flag", "this is a flag."); parser.add_flag(option_value2, 'f', "false-flag", "this is a flag."); @@ -95,7 +95,7 @@ TEST(parse_type_test, add_flag_short_id_multiple) bool option_value4{false}; const char * argv[] = {"./argument_parser_test", "-tab"}; - seqan3::argument_parser parser{"test_parser", 2, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 2, argv, sharg::update_notifications::off}; parser.add_flag(option_value1, 't', "true-flag", "this is a flag."); parser.add_flag(option_value2, 'f', "false-flag", "this is a flag."); parser.add_flag(option_value3, 'a', "additional-flag", "this is a flag."); @@ -116,7 +116,7 @@ TEST(parse_type_test, add_flag_long_id) bool option_value2{true}; const char * argv[] = {"./argument_parser_test", "--true-flag"}; - seqan3::argument_parser parser{"test_parser", 2, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 2, argv, sharg::update_notifications::off}; parser.add_flag(option_value1, 't', "true-flag", "this is a flag."); parser.add_flag(option_value2, 'f', "false-flag", "this is a flag."); @@ -132,7 +132,7 @@ TEST(parse_type_test, add_positional_option) std::string positional_value; const char * argv[] = {"./argument_parser_test", "positional_string"}; - seqan3::argument_parser parser{"test_parser", 2, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 2, argv, sharg::update_notifications::off}; parser.add_positional_option(positional_value, "this is a string positional."); testing::internal::CaptureStderr(); @@ -151,7 +151,7 @@ TEST(parse_type_test, independent_add_order) // Order 1: option, flag, positional const char * argv[] = {"./argument_parser_test", "-i", "2", "-b", "arg"}; - seqan3::argument_parser parser{"test_parser", 5, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 5, argv, sharg::update_notifications::off}; parser.add_option(option_value, 'i', "int-option", "this is a int option."); parser.add_flag(flag_value, 'b', "flag", "this is a flag."); parser.add_positional_option(positional_value, "this is a string positional."); @@ -164,7 +164,7 @@ TEST(parse_type_test, independent_add_order) EXPECT_EQ(flag_value, true); // Order 1: flag, option, positional - seqan3::argument_parser parser2{"test_parser", 5, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser2{"test_parser", 5, argv, sharg::update_notifications::off}; parser2.add_flag(flag_value, 'b', "flag", "this is a flag."); parser2.add_option(option_value, 'i', "int-option", "this is a int option."); parser2.add_positional_option(positional_value, "this is a string positional."); @@ -177,7 +177,7 @@ TEST(parse_type_test, independent_add_order) EXPECT_EQ(flag_value, true); // Order 1: option, positional, flag - seqan3::argument_parser parser3{"test_parser", 5, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser3{"test_parser", 5, argv, sharg::update_notifications::off}; parser3.add_option(option_value, 'i', "int-option", "this is a int option."); parser3.add_positional_option(positional_value, "this is a string positional."); parser3.add_flag(flag_value, 'b', "flag", "this is a flag."); @@ -190,7 +190,7 @@ TEST(parse_type_test, independent_add_order) EXPECT_EQ(flag_value, true); // Order 1: flag, positional, option - seqan3::argument_parser parser4{"test_parser", 5, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser4{"test_parser", 5, argv, sharg::update_notifications::off}; parser4.add_flag(flag_value, 'b', "flag", "this is a flag."); parser4.add_positional_option(positional_value, "this is a string positional."); parser4.add_option(option_value, 'i', "int-option", "this is a int option."); @@ -203,7 +203,7 @@ TEST(parse_type_test, independent_add_order) EXPECT_EQ(flag_value, true); // Order 1: positional, flag, option - seqan3::argument_parser parser5{"test_parser", 5, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser5{"test_parser", 5, argv, sharg::update_notifications::off}; parser5.add_positional_option(positional_value, "this is a string positional."); parser5.add_flag(flag_value, 'b', "flag", "this is a flag."); parser5.add_option(option_value, 'i', "int-option", "this is a int option."); @@ -216,7 +216,7 @@ TEST(parse_type_test, independent_add_order) EXPECT_EQ(flag_value, true); // Order 1: positional, option, flag - seqan3::argument_parser parser6{"test_parser", 5, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser6{"test_parser", 5, argv, sharg::update_notifications::off}; parser6.add_positional_option(positional_value, "this is a string positional."); parser6.add_option(option_value, 'i', "int-option", "this is a int option."); parser6.add_flag(flag_value, 'b', "flag", "this is a flag."); @@ -239,7 +239,7 @@ TEST(parse_type_test, independent_cmd_order) // Order 1: option, flag, positional (POSIX conform) const char * argv[] = {"./argument_parser_test", "-i", "2", "-b", "arg"}; - seqan3::argument_parser parser{"test_parser", 5, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 5, argv, sharg::update_notifications::off}; parser.add_option(option_value, 'i', "int-option", "this is a int option."); parser.add_flag(flag_value, 'b', "flag", "this is a flag."); parser.add_positional_option(positional_value, "this is a string positional."); @@ -253,7 +253,7 @@ TEST(parse_type_test, independent_cmd_order) // Order 1: flag, option, positional (POSIX conform) const char * argv2[] = {"./argument_parser_test", "-b", "-i", "2", "arg"}; - seqan3::argument_parser parser2{"test_parser", 5, argv2, seqan3::update_notifications::off}; + sharg::argument_parser parser2{"test_parser", 5, argv2, sharg::update_notifications::off}; parser2.add_option(option_value, 'i', "int-option", "this is a int option."); parser2.add_flag(flag_value, 'b', "flag", "this is a flag."); parser2.add_positional_option(positional_value, "this is a string positional."); @@ -267,7 +267,7 @@ TEST(parse_type_test, independent_cmd_order) // Order 1: option, positional, flag const char * argv3[] = {"./argument_parser_test", "-i", "2", "arg", "-b"}; - seqan3::argument_parser parser3{"test_parser", 5, argv3, seqan3::update_notifications::off}; + sharg::argument_parser parser3{"test_parser", 5, argv3, sharg::update_notifications::off}; parser3.add_option(option_value, 'i', "int-option", "this is a int option."); parser3.add_flag(flag_value, 'b', "flag", "this is a flag."); parser3.add_positional_option(positional_value, "this is a string positional."); @@ -281,7 +281,7 @@ TEST(parse_type_test, independent_cmd_order) // Order 1: flag, positional, option const char * argv4[] = {"./argument_parser_test", "-b", "arg", "-i", "2"}; - seqan3::argument_parser parser4{"test_parser", 5, argv4, seqan3::update_notifications::off}; + sharg::argument_parser parser4{"test_parser", 5, argv4, sharg::update_notifications::off}; parser4.add_option(option_value, 'i', "int-option", "this is a int option."); parser4.add_flag(flag_value, 'b', "flag", "this is a flag."); parser4.add_positional_option(positional_value, "this is a string positional."); @@ -295,7 +295,7 @@ TEST(parse_type_test, independent_cmd_order) // Order 1: positional, flag, option const char * argv5[] = {"./argument_parser_test", "arg", "-b", "-i", "2"}; - seqan3::argument_parser parser5{"test_parser", 5, argv5, seqan3::update_notifications::off}; + sharg::argument_parser parser5{"test_parser", 5, argv5, sharg::update_notifications::off}; parser5.add_option(option_value, 'i', "int-option", "this is a int option."); parser5.add_flag(flag_value, 'b', "flag", "this is a flag."); parser5.add_positional_option(positional_value, "this is a string positional."); @@ -309,7 +309,7 @@ TEST(parse_type_test, independent_cmd_order) // Order 1: positional, option, flag const char * argv6[] = {"./argument_parser_test", "arg", "-i", "2", "-b"}; - seqan3::argument_parser parser6{"test_parser", 5, argv6, seqan3::update_notifications::off}; + sharg::argument_parser parser6{"test_parser", 5, argv6, sharg::update_notifications::off}; parser6.add_option(option_value, 'i', "int-option", "this is a int option."); parser6.add_flag(flag_value, 'b', "flag", "this is a flag."); parser6.add_positional_option(positional_value, "this is a string positional."); @@ -328,7 +328,7 @@ TEST(parse_test, double_dash_separation_success) // string option with dash const char * argv[] = {"./argument_parser_test", "--", "-strange"}; - seqan3::argument_parser parser{"test_parser", 3, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 3, argv, sharg::update_notifications::off}; parser.add_positional_option(option_value, "this is a string option."); testing::internal::CaptureStderr(); @@ -339,7 +339,7 @@ TEST(parse_test, double_dash_separation_success) // negative integer option int option_value_int; const char * argv2[] = {"./argument_parser_test", "--", "-120"}; - seqan3::argument_parser parser2{"test_parser", 3, argv2, seqan3::update_notifications::off}; + sharg::argument_parser parser2{"test_parser", 3, argv2, sharg::update_notifications::off}; parser2.add_positional_option(option_value_int, "this is a int option."); testing::internal::CaptureStderr(); @@ -355,7 +355,7 @@ TEST(parse_test, special_characters_as_value_success) // weird option value. But since r/regex option is parsed and with it's // value should work correct const char * argv[] = {"./argument_parser_test", "--regex", "-i=/45*&//--"}; - seqan3::argument_parser parser{"test_parser", 3, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 3, argv, sharg::update_notifications::off}; parser.add_option(option_value, 'r', "regex", "strange option value."); testing::internal::CaptureStderr(); @@ -370,31 +370,31 @@ TEST(parse_test, empty_value_error) // short option const char * argv[] = {"./argument_parser_test", "-i"}; - seqan3::argument_parser parser{"test_parser", 2, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 2, argv, sharg::update_notifications::off}; parser.add_option(option_value, 'i', "long", "this is a int option."); - EXPECT_THROW(parser.parse(), seqan3::argument_parser_error); + EXPECT_THROW(parser.parse(), sharg::argument_parser_error); // long option const char * argv2[] = {"./argument_parser_test", "--long"}; - seqan3::argument_parser parser2{"test_parser", 2, argv2, seqan3::update_notifications::off}; + sharg::argument_parser parser2{"test_parser", 2, argv2, sharg::update_notifications::off}; parser2.add_option(option_value, 'i', "long", "this is an int option."); - EXPECT_THROW(parser2.parse(), seqan3::argument_parser_error); + EXPECT_THROW(parser2.parse(), sharg::argument_parser_error); // short option const char * argv3[] = {"./argument_parser_test", "-i="}; - seqan3::argument_parser parser3{"test_parser", 2, argv3, seqan3::update_notifications::off}; + sharg::argument_parser parser3{"test_parser", 2, argv3, sharg::update_notifications::off}; parser3.add_option(option_value, 'i', "long", "this is an int option."); - EXPECT_THROW(parser3.parse(), seqan3::argument_parser_error); + EXPECT_THROW(parser3.parse(), sharg::argument_parser_error); // short option const char * argv4[] = {"./argument_parser_test", "--long="}; - seqan3::argument_parser parser4{"test_parser", 2, argv4, seqan3::update_notifications::off}; + sharg::argument_parser parser4{"test_parser", 2, argv4, sharg::update_notifications::off}; parser4.add_option(option_value, 'i', "long", "this is an int option."); - EXPECT_THROW(parser4.parse(), seqan3::argument_parser_error); + EXPECT_THROW(parser4.parse(), sharg::argument_parser_error); } TEST(parse_type_test, parse_success_bool_option) @@ -405,7 +405,7 @@ TEST(parse_type_test, parse_success_bool_option) // numbers 0 and 1 { const char * argv[] = {"./argument_parser_test", "-b", "1", "0"}; - seqan3::argument_parser parser{"test_parser", 4, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 4, argv, sharg::update_notifications::off}; parser.add_option(option_value, 'b', "bool-option", "this is a bool option."); parser.add_positional_option(positional_value, "this is a bool positional."); @@ -420,7 +420,7 @@ TEST(parse_type_test, parse_success_bool_option) // true and false { const char * argv[] = {"./argument_parser_test", "-b", "true", "false"}; - seqan3::argument_parser parser{"test_parser", 4, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 4, argv, sharg::update_notifications::off}; parser.add_option(option_value, 'b', "bool-option", "this is a bool option."); parser.add_positional_option(positional_value, "this is a bool positional."); @@ -439,7 +439,7 @@ TEST(parse_type_test, parse_success_int_option) size_t positional_value; const char * argv[] = {"./argument_parser_test", "-i", "-2", "278"}; - seqan3::argument_parser parser{"test_parser", 4, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 4, argv, sharg::update_notifications::off}; parser.add_option(option_value, 'i', "int-option", "this is a int option."); parser.add_positional_option(positional_value, "this is a int positional."); @@ -457,7 +457,7 @@ TEST(parse_type_test, parse_success_double_option) double positional_value; const char * argv[] = {"./argument_parser_test", "-d", "12.457", "0.123"}; - seqan3::argument_parser parser{"test_parser", 4, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 4, argv, sharg::update_notifications::off}; parser.add_option(option_value, 'd', "double-option", "this is a double option."); parser.add_positional_option(positional_value, "this is a double positional."); @@ -470,7 +470,7 @@ TEST(parse_type_test, parse_success_double_option) // double expression with e const char * argv2[] = {"./argument_parser_test", "-d", "6.0221418e23"}; - seqan3::argument_parser parser2{"test_parser", 3, argv2, seqan3::update_notifications::off}; + sharg::argument_parser parser2{"test_parser", 3, argv2, sharg::update_notifications::off}; parser2.add_option(option_value, 'd', "double-option", "this is a double option."); testing::internal::CaptureStderr(); @@ -488,17 +488,17 @@ TEST(parse_type_test, parse_error_bool_option) // fail on character input const char * argv[] = {"./argument_parser_test", "-b", "a"}; - seqan3::argument_parser parser{"test_parser", 3, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 3, argv, sharg::update_notifications::off}; parser.add_option(option_value, 'b', "bool-option", "this is a bool option."); - EXPECT_THROW(parser.parse(), seqan3::argument_parser_error); + EXPECT_THROW(parser.parse(), sharg::argument_parser_error); // fail on number input expect 0 and 1 const char * argv2[] = {"./argument_parser_test", "-b", "124"}; - seqan3::argument_parser parser2{"test_parser", 3, argv2, seqan3::update_notifications::off}; + sharg::argument_parser parser2{"test_parser", 3, argv2, sharg::update_notifications::off}; parser2.add_option(option_value, 'b', "bool-option", "this is a bool option."); - EXPECT_THROW(parser2.parse(), seqan3::argument_parser_error); + EXPECT_THROW(parser2.parse(), sharg::argument_parser_error); } TEST(parse_type_test, parse_error_int_option) @@ -507,47 +507,47 @@ TEST(parse_type_test, parse_error_int_option) // fail on character const char * argv[] = {"./argument_parser_test", "-i", "abc"}; - seqan3::argument_parser parser{"test_parser", 3, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 3, argv, sharg::update_notifications::off}; parser.add_option(option_value, 'i', "int-option", "this is a int option."); - EXPECT_THROW(parser.parse(), seqan3::argument_parser_error); + EXPECT_THROW(parser.parse(), sharg::argument_parser_error); // fail on number followed by character const char * argv2[] = {"./argument_parser_test", "-i", "2abc"}; - seqan3::argument_parser parser2{"test_parser", 3, argv2, seqan3::update_notifications::off}; + sharg::argument_parser parser2{"test_parser", 3, argv2, sharg::update_notifications::off}; parser2.add_option(option_value, 'i', "int-option", "this is a int option."); - EXPECT_THROW(parser2.parse(), seqan3::argument_parser_error); + EXPECT_THROW(parser2.parse(), sharg::argument_parser_error); // fail on double const char * argv3[] = {"./argument_parser_test", "-i", "3.12"}; - seqan3::argument_parser parser3{"test_parser", 3, argv3, seqan3::update_notifications::off}; + sharg::argument_parser parser3{"test_parser", 3, argv3, sharg::update_notifications::off}; parser3.add_option(option_value, 'i', "int-option", "this is a int option."); - EXPECT_THROW(parser3.parse(), seqan3::argument_parser_error); + EXPECT_THROW(parser3.parse(), sharg::argument_parser_error); // fail on negative number for unsigned unsigned option_value_u; const char * argv4[] = {"./argument_parser_test", "-i", "-1"}; - seqan3::argument_parser parser4{"test_parser", 3, argv4, seqan3::update_notifications::off}; + sharg::argument_parser parser4{"test_parser", 3, argv4, sharg::update_notifications::off}; parser4.add_option(option_value_u, 'i', "int-option", "this is a int option."); - EXPECT_THROW(parser4.parse(), seqan3::argument_parser_error); + EXPECT_THROW(parser4.parse(), sharg::argument_parser_error); // fail on overflow int8_t option_value_int8; const char * argv5[] = {"./argument_parser_test", "-i", "129"}; - seqan3::argument_parser parser5{"test_parser", 3, argv5, seqan3::update_notifications::off}; + sharg::argument_parser parser5{"test_parser", 3, argv5, sharg::update_notifications::off}; parser5.add_option(option_value_int8, 'i', "int-option", "this is a int option."); - EXPECT_THROW(parser5.parse(), seqan3::argument_parser_error); + EXPECT_THROW(parser5.parse(), sharg::argument_parser_error); uint8_t option_value_uint8; const char * argv6[] = {"./argument_parser_test", "-i", "267"}; - seqan3::argument_parser parser6{"test_parser", 3, argv6, seqan3::update_notifications::off}; + sharg::argument_parser parser6{"test_parser", 3, argv6, sharg::update_notifications::off}; parser6.add_option(option_value_uint8, 'i', "int-option", "this is a int option."); - EXPECT_THROW(parser6.parse(), seqan3::argument_parser_error); + EXPECT_THROW(parser6.parse(), sharg::argument_parser_error); } TEST(parse_type_test, parse_error_double_option) @@ -556,17 +556,17 @@ TEST(parse_type_test, parse_error_double_option) // fail on character const char * argv[] = {"./argument_parser_test", "-i", "abc"}; - seqan3::argument_parser parser{"test_parser", 3, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 3, argv, sharg::update_notifications::off}; parser.add_option(option_value, 'd', "double-option", "this is a double option."); - EXPECT_THROW(parser.parse(), seqan3::argument_parser_error); + EXPECT_THROW(parser.parse(), sharg::argument_parser_error); // fail on number followed by character const char * argv2[] = {"./argument_parser_test", "-d", "12.457a"}; - seqan3::argument_parser parser2{"test_parser", 3, argv2, seqan3::update_notifications::off}; + sharg::argument_parser parser2{"test_parser", 3, argv2, sharg::update_notifications::off}; parser2.add_option(option_value, 'd', "double-option", "this is a double option."); - EXPECT_THROW(parser2.parse(), seqan3::argument_parser_error); + EXPECT_THROW(parser2.parse(), sharg::argument_parser_error); } TEST(parse_test, too_many_arguments_error) @@ -574,18 +574,18 @@ TEST(parse_test, too_many_arguments_error) int option_value; const char * argv[] = {"./argument_parser_test", "5", "15"}; - seqan3::argument_parser parser{"test_parser", 3, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 3, argv, sharg::update_notifications::off}; parser.add_positional_option(option_value, "this is an int option."); - EXPECT_THROW(parser.parse(), seqan3::too_many_arguments); + EXPECT_THROW(parser.parse(), sharg::too_many_arguments); // since -- indicates -i as a positional argument, this causes a too many args error const char * argv2[] = {"./argument_parser_test", "2", "--", "-i"}; - seqan3::argument_parser parser2{"test_parser", 4, argv2, seqan3::update_notifications::off}; + sharg::argument_parser parser2{"test_parser", 4, argv2, sharg::update_notifications::off}; parser2.add_positional_option(option_value, "normal int positional argument."); parser2.add_option(option_value, 'i', "int-option", "this is an int option."); - EXPECT_THROW(parser2.parse(), seqan3::too_many_arguments); + EXPECT_THROW(parser2.parse(), sharg::too_many_arguments); } TEST(parse_test, too_few_arguments_error) @@ -593,64 +593,64 @@ TEST(parse_test, too_few_arguments_error) int option_value; const char * argv[] = {"./argument_parser_test", "15"}; - seqan3::argument_parser parser{"test_parser", 2, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 2, argv, sharg::update_notifications::off}; parser.add_positional_option(option_value, "this is an int option."); parser.add_positional_option(option_value, "this is another option."); - EXPECT_THROW(parser.parse(), seqan3::too_few_arguments); + EXPECT_THROW(parser.parse(), sharg::too_few_arguments); // since -- indicates -i as a positional argument, this causes a too many args error const char * argv2[] = {"./argument_parser_test", "-i", "2"}; - seqan3::argument_parser parser2{"test_parser", 3, argv2, seqan3::update_notifications::off}; + sharg::argument_parser parser2{"test_parser", 3, argv2, sharg::update_notifications::off}; parser2.add_positional_option(option_value, "normal int positional argument."); parser2.add_option(option_value, 'i', "int-option", "this is an int option."); - EXPECT_THROW(parser2.parse(), seqan3::too_few_arguments); + EXPECT_THROW(parser2.parse(), sharg::too_few_arguments); } TEST(parse_test, unknown_option_error) { // unknown short option const char * argv[] = {"./argument_parser_test", "-i", "15"}; - seqan3::argument_parser parser{"test_parser", 3, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 3, argv, sharg::update_notifications::off}; - EXPECT_THROW(parser.parse(), seqan3::unknown_option); + EXPECT_THROW(parser.parse(), sharg::unknown_option); // unknown long option const char * argv2[] = {"./argument_parser_test", "--arg", "8"}; - seqan3::argument_parser parser2{"test_parser", 3, argv2, seqan3::update_notifications::off}; + sharg::argument_parser parser2{"test_parser", 3, argv2, sharg::update_notifications::off}; - EXPECT_THROW(parser2.parse(), seqan3::unknown_option); + EXPECT_THROW(parser2.parse(), sharg::unknown_option); // unknown short flag const char * argv3[] = {"./argument_parser_test", "-a"}; - seqan3::argument_parser parser3{"test_parser", 2, argv3, seqan3::update_notifications::off}; + sharg::argument_parser parser3{"test_parser", 2, argv3, sharg::update_notifications::off}; - EXPECT_THROW(parser3.parse(), seqan3::unknown_option); + EXPECT_THROW(parser3.parse(), sharg::unknown_option); // unknown long flag const char * argv4[] = {"./argument_parser_test", "--arg"}; - seqan3::argument_parser parser4{"test_parser", 2, argv4, seqan3::update_notifications::off}; + sharg::argument_parser parser4{"test_parser", 2, argv4, sharg::update_notifications::off}; - EXPECT_THROW(parser4.parse(), seqan3::unknown_option); + EXPECT_THROW(parser4.parse(), sharg::unknown_option); // negative numbers are seen as options const char * argv5[] = {"./argument_parser_test", "-5"}; - seqan3::argument_parser parser5{"test_parser", 2, argv5, seqan3::update_notifications::off}; + sharg::argument_parser parser5{"test_parser", 2, argv5, sharg::update_notifications::off}; - EXPECT_THROW(parser5.parse(), seqan3::unknown_option); + EXPECT_THROW(parser5.parse(), sharg::unknown_option); // unknown short option in more complex command line int option_value_i; std::string option_value_a; std::string positional_option; const char * argv6[] = {"./argument_parser_test", "-i", "129", "arg1", "-b", "bcd", "-a", "abc"}; - seqan3::argument_parser parser6{"test_parser", 8, argv6, seqan3::update_notifications::off}; + sharg::argument_parser parser6{"test_parser", 8, argv6, sharg::update_notifications::off}; parser6.add_option(option_value_i, 'i', "int-option", "this is a int option."); parser6.add_option(option_value_a, 'a', "string-option", "this is a string option."); parser6.add_positional_option(positional_option, "normal int positional argument."); - EXPECT_THROW(parser6.parse(), seqan3::unknown_option); + EXPECT_THROW(parser6.parse(), sharg::unknown_option); } TEST(parse_test, option_declared_multiple_times_error) @@ -659,24 +659,24 @@ TEST(parse_test, option_declared_multiple_times_error) // short option const char * argv[] = {"./argument_parser_test", "-i", "15", "-i", "3"}; - seqan3::argument_parser parser{"test_parser", 5, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 5, argv, sharg::update_notifications::off}; parser.add_option(option_value, 'i', "long", "this is a int option."); - EXPECT_THROW(parser.parse(), seqan3::option_declared_multiple_times); + EXPECT_THROW(parser.parse(), sharg::option_declared_multiple_times); // since -- indicates -i as a positional argument, this causes a too many args error const char * argv2[] = {"./argument_parser_test", "--long", "5", "--long", "6"}; - seqan3::argument_parser parser2{"test_parser", 5, argv2, seqan3::update_notifications::off}; + sharg::argument_parser parser2{"test_parser", 5, argv2, sharg::update_notifications::off}; parser2.add_option(option_value, 'i', "long", "this is an int option."); - EXPECT_THROW(parser2.parse(), seqan3::option_declared_multiple_times); + EXPECT_THROW(parser2.parse(), sharg::option_declared_multiple_times); // since -- indicates -i as a positional argument, this causes a too many args error const char * argv3[] = {"./argument_parser_test", "-i", "5", "--long", "6"}; - seqan3::argument_parser parser3{"test_parser", 5, argv3, seqan3::update_notifications::off}; + sharg::argument_parser parser3{"test_parser", 5, argv3, sharg::update_notifications::off}; parser3.add_option(option_value, 'i', "long", "this is an int option."); - EXPECT_THROW(parser3.parse(), seqan3::option_declared_multiple_times); + EXPECT_THROW(parser3.parse(), sharg::option_declared_multiple_times); } TEST(parse_test, required_option_missing) @@ -685,12 +685,12 @@ TEST(parse_test, required_option_missing) // option is required const char * argv[] = {"./argument_parser_test", "5", "-i", "15"}; - seqan3::argument_parser parser{"test_parser", 4, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 4, argv, sharg::update_notifications::off}; parser.add_option(option_value, 'i', "int-option", "this is an int option."); - parser.add_option(option_value, 'a', "req-option", "I am required.", seqan3::option_spec::required); + parser.add_option(option_value, 'a', "req-option", "I am required.", sharg::option_spec::required); parser.add_positional_option(option_value, "this is an int option."); - EXPECT_THROW(parser.parse(), seqan3::required_option_missing); + EXPECT_THROW(parser.parse(), sharg::required_option_missing); } TEST(parse_test, argv_const_combinations) @@ -703,7 +703,7 @@ TEST(parse_test, argv_const_combinations) // all const* char const * const * const argv_all_const{argv}; - seqan3::argument_parser parser{"test_parser", 2, argv_all_const, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 2, argv_all_const, sharg::update_notifications::off}; parser.add_flag(flag_value, 'f', "flag", "this is a flag."); EXPECT_NO_THROW(parser.parse()); @@ -711,7 +711,7 @@ TEST(parse_test, argv_const_combinations) // none const flag_value = false; - parser = seqan3::argument_parser{"test_parser", 2, argv, seqan3::update_notifications::off}; + parser = sharg::argument_parser{"test_parser", 2, argv, sharg::update_notifications::off}; parser.add_flag(flag_value, 'f', "flag", "this is a flag."); EXPECT_NO_THROW(parser.parse()); @@ -720,7 +720,7 @@ TEST(parse_test, argv_const_combinations) // const 1 flag_value = false; char const * argv_const1[] = {"./argument_parser_test", "-f"}; - parser = seqan3::argument_parser{"test_parser", 2, argv_const1, seqan3::update_notifications::off}; + parser = sharg::argument_parser{"test_parser", 2, argv_const1, sharg::update_notifications::off}; parser.add_flag(flag_value, 'f', "flag", "this is a flag."); EXPECT_NO_THROW(parser.parse()); @@ -729,7 +729,7 @@ TEST(parse_test, argv_const_combinations) // const 2 flag_value = false; char * const argv_const2[] = {arg1, arg2}; - parser = seqan3::argument_parser{"test_parser", 2, argv_const2, seqan3::update_notifications::off}; + parser = sharg::argument_parser{"test_parser", 2, argv_const2, sharg::update_notifications::off}; parser.add_flag(flag_value, 'f', "flag", "this is a flag."); EXPECT_NO_THROW(parser.parse()); @@ -738,7 +738,7 @@ TEST(parse_test, argv_const_combinations) // const 12 flag_value = false; char const * const argv_const12[] = {arg1, arg2}; - parser = seqan3::argument_parser{"test_parser", 2, argv_const12, seqan3::update_notifications::off}; + parser = sharg::argument_parser{"test_parser", 2, argv_const12, sharg::update_notifications::off}; parser.add_flag(flag_value, 'f', "flag", "this is a flag."); EXPECT_NO_THROW(parser.parse()); @@ -751,7 +751,7 @@ TEST(parse_test, multiple_empty_options) { const char * argv[]{"./empty_long", "-s=1"}; - seqan3::argument_parser parser{"empty_long", 2, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"empty_long", 2, argv, sharg::update_notifications::off}; parser.add_option(option_value, 'i', "", "no long"); parser.add_option(option_value, 's', "", "no long"); @@ -761,16 +761,16 @@ TEST(parse_test, multiple_empty_options) { const char * argv[]{"./empty_long", "-s=1", "--unknown"}; - seqan3::argument_parser parser{"empty_long", 3, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"empty_long", 3, argv, sharg::update_notifications::off}; parser.add_option(option_value, 'i', "", "no long"); parser.add_option(option_value, 's', "", "no long"); - EXPECT_THROW(parser.parse(), seqan3::unknown_option); + EXPECT_THROW(parser.parse(), sharg::unknown_option); } { const char * argv[]{"./empty_short", "--long=2"}; - seqan3::argument_parser parser{"empty_short", 2, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"empty_short", 2, argv, sharg::update_notifications::off}; parser.add_option(option_value, '\0', "longi", "no short"); parser.add_option(option_value, '\0', "long", "no short"); @@ -783,12 +783,12 @@ TEST(parse_test, version_check_option_error) { { // version-check must be followed by a value const char * argv[] = {"./argument_parser_test", "--version-check"}; - EXPECT_THROW((seqan3::argument_parser{"test_parser", 2, argv}), seqan3::argument_parser_error); + EXPECT_THROW((sharg::argument_parser{"test_parser", 2, argv}), sharg::argument_parser_error); } { // version-check value must be 0 or 1 const char * argv[] = {"./argument_parser_test", "--version-check", "foo"}; - EXPECT_THROW((seqan3::argument_parser{"test_parser", 3, argv}), seqan3::argument_parser_error); + EXPECT_THROW((sharg::argument_parser{"test_parser", 3, argv}), sharg::argument_parser_error); } } @@ -800,17 +800,17 @@ TEST(parse_test, subcommand_argument_parser_success) // parsing { const char * argv[]{"./top_level", "-f", "sub1", "foo"}; - seqan3::argument_parser top_level_parser{"top_level", + sharg::argument_parser top_level_parser{"top_level", 4, argv, - seqan3::update_notifications::off, + sharg::update_notifications::off, {"sub1", "sub2"}}; top_level_parser.add_flag(flag_value, 'f', "foo", "foo bar"); EXPECT_NO_THROW(top_level_parser.parse()); EXPECT_EQ(true, flag_value); - seqan3::argument_parser & sub_parser = top_level_parser.get_sub_parser(); + sharg::argument_parser & sub_parser = top_level_parser.get_sub_parser(); EXPECT_EQ(sub_parser.info.app_name, "top_level-sub1"); @@ -823,10 +823,10 @@ TEST(parse_test, subcommand_argument_parser_success) // top-level help page { const char * argv[]{"./top_level", "-h", "-f", "sub1", "foo"}; - seqan3::argument_parser top_level_parser{"top_level", + sharg::argument_parser top_level_parser{"top_level", 5, argv, - seqan3::update_notifications::off, + sharg::update_notifications::off, {"sub1", "sub2"}}; top_level_parser.add_flag(flag_value, 'f', "foo", "foo bar"); @@ -838,17 +838,17 @@ TEST(parse_test, subcommand_argument_parser_success) // sub-parser help page { const char * argv[]{"./top_level", "-f", "sub1", "-h"}; - seqan3::argument_parser top_level_parser{"top_level", + sharg::argument_parser top_level_parser{"top_level", 4, argv, - seqan3::update_notifications::off, + sharg::update_notifications::off, {"sub1", "sub2"}}; top_level_parser.add_flag(flag_value, 'f', "foo", "foo bar"); EXPECT_NO_THROW(top_level_parser.parse()); EXPECT_EQ(true, flag_value); - seqan3::argument_parser & sub_parser = top_level_parser.get_sub_parser(); + sharg::argument_parser & sub_parser = top_level_parser.get_sub_parser(); EXPECT_EQ(sub_parser.info.app_name, "top_level-sub1"); @@ -862,21 +862,21 @@ TEST(parse_test, subcommand_argument_parser_success) // incorrect sub command const char * argv[]{"./top_level", "subiddysub", "-f"}; { // see issue https://github.com/seqan/seqan3/issues/2172 - seqan3::argument_parser top_level_parser{"top_level", + sharg::argument_parser top_level_parser{"top_level", 3, argv, - seqan3::update_notifications::off, + sharg::update_notifications::off, {"sub1", "sub2"}}; - EXPECT_THROW(top_level_parser.parse(), seqan3::argument_parser_error); + EXPECT_THROW(top_level_parser.parse(), sharg::argument_parser_error); } // sub command can contain dash, see https://github.com/seqan/product_backlog/issues/234 { - EXPECT_NO_THROW((seqan3::argument_parser{"top_level", + EXPECT_NO_THROW((sharg::argument_parser{"top_level", 2, argv, - seqan3::update_notifications::off, + sharg::update_notifications::off, {"-dash"}})); } } @@ -886,35 +886,35 @@ TEST(parse_test, issue1544) { // wrong separation of long value: std::string option_value; const char * argv[] = {"./argument_parser_test", "--foohallo"}; - seqan3::argument_parser parser{"test_parser", 2, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 2, argv, sharg::update_notifications::off}; parser.add_option(option_value, 'f', "foo", "this is a string option."); - EXPECT_THROW(parser.parse(), seqan3::unknown_option); + EXPECT_THROW(parser.parse(), sharg::unknown_option); } { // unknown option (`--foo-bar`) that has a prefix of a known option (`--foo`) std::string option_value; const char * argv[] = {"./argument_parser_test", "--foo", "hallo", "--foo-bar", "ballo"}; - seqan3::argument_parser parser{"test_parser", 5, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 5, argv, sharg::update_notifications::off}; parser.add_option(option_value, 'f', "foo", "this is a string option."); - EXPECT_THROW(parser.parse(), seqan3::unknown_option); + EXPECT_THROW(parser.parse(), sharg::unknown_option); } { // known option (`--foo-bar`) that has a prefix of a unknown option (`--foo`) std::string option_value; const char * argv[] = {"./argument_parser_test", "--foo", "hallo", "--foo-bar", "ballo"}; - seqan3::argument_parser parser{"test_parser", 5, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 5, argv, sharg::update_notifications::off}; parser.add_option(option_value, 'f', "foo-bar", "this is a string option."); - EXPECT_THROW(parser.parse(), seqan3::unknown_option); + EXPECT_THROW(parser.parse(), sharg::unknown_option); } { // known option (`--foo`) is a prefix of another known option (`--foo-bar`) std::string foo_option_value; std::string foobar_option_value; const char * argv[] = {"./argument_parser_test", "--foo", "hallo", "--foo-bar", "ballo"}; - seqan3::argument_parser parser{"test_parser", 5, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 5, argv, sharg::update_notifications::off}; parser.add_option(foo_option_value, 'f', "foo", "this is a prefix of foobar."); parser.add_option(foobar_option_value, 'b', "foo-bar", "this has prefix foo."); @@ -928,11 +928,11 @@ TEST(parse_test, is_option_set) { std::string option_value{}; const char * argv[] = {"./argument_parser_test", "-l", "hallo", "--foobar", "ballo", "--", "--loo"}; - seqan3::argument_parser parser{"test_parser", 5, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 5, argv, sharg::update_notifications::off}; parser.add_option(option_value, 'l', "loo", "this is a option."); parser.add_option(option_value, 'f', "foobar", "this is a option."); - EXPECT_THROW(parser.is_option_set("foo"), seqan3::design_error); // you cannot call option_is_set before parse() + EXPECT_THROW(parser.is_option_set("foo"), sharg::design_error); // you cannot call option_is_set before parse() EXPECT_NO_THROW(parser.parse()); @@ -943,17 +943,17 @@ TEST(parse_test, is_option_set) EXPECT_FALSE(parser.is_option_set("loo")); // --loo is behind the `--` which signals the end of options! // errors: - EXPECT_THROW(parser.is_option_set("l"), seqan3::design_error); // short identifiers are passed as chars not strings - EXPECT_THROW(parser.is_option_set("f"), seqan3::design_error); // short identifiers are passed as chars not strings + EXPECT_THROW(parser.is_option_set("l"), sharg::design_error); // short identifiers are passed as chars not strings + EXPECT_THROW(parser.is_option_set("f"), sharg::design_error); // short identifiers are passed as chars not strings - EXPECT_THROW(parser.is_option_set("foo"), seqan3::design_error); - EXPECT_THROW(parser.is_option_set("--"), seqan3::design_error); - EXPECT_THROW(parser.is_option_set(""), seqan3::design_error); + EXPECT_THROW(parser.is_option_set("foo"), sharg::design_error); + EXPECT_THROW(parser.is_option_set("--"), sharg::design_error); + EXPECT_THROW(parser.is_option_set(""), sharg::design_error); - EXPECT_THROW(parser.is_option_set('!'), seqan3::design_error); - EXPECT_THROW(parser.is_option_set('-'), seqan3::design_error); - EXPECT_THROW(parser.is_option_set('_'), seqan3::design_error); - EXPECT_THROW(parser.is_option_set('\0'), seqan3::design_error); + EXPECT_THROW(parser.is_option_set('!'), sharg::design_error); + EXPECT_THROW(parser.is_option_set('-'), sharg::design_error); + EXPECT_THROW(parser.is_option_set('_'), sharg::design_error); + EXPECT_THROW(parser.is_option_set('\0'), sharg::design_error); } namespace foo @@ -980,7 +980,7 @@ enum class bar }; } // namespace Other -namespace seqan3::custom +namespace sharg::custom { template <> struct argument_parsing @@ -990,7 +990,7 @@ struct argument_parsing {"one", Other::bar::one}, {"1", Other::bar::one}, {"two", Other::bar::two}, {"2", Other::bar::two} }; }; -} // namespace seqan3::custom +} // namespace sharg::custom TEST(parse_type_test, parse_success_enum_option) { @@ -998,7 +998,7 @@ TEST(parse_type_test, parse_success_enum_option) foo::bar option_value{}; const char * argv[] = {"./argument_parser_test", "-e", "two"}; - seqan3::argument_parser parser{"test_parser", 3, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 3, argv, sharg::update_notifications::off}; parser.add_option(option_value, 'e', "enum-option", "this is an enum option."); EXPECT_NO_THROW(parser.parse()); @@ -1009,7 +1009,7 @@ TEST(parse_type_test, parse_success_enum_option) Other::bar option_value{}; const char * argv[] = {"./argument_parser_test", "-e", "two"}; - seqan3::argument_parser parser{"test_parser", 3, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 3, argv, sharg::update_notifications::off}; parser.add_option(option_value, 'e', "enum-option", "this is an enum option."); EXPECT_NO_THROW(parser.parse()); @@ -1022,10 +1022,10 @@ TEST(parse_type_test, parse_error_enum_option) foo::bar option_value{}; const char * argv[] = {"./argument_parser_test", "-e", "four"}; - seqan3::argument_parser parser{"test_parser", 3, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 3, argv, sharg::update_notifications::off}; parser.add_option(option_value, 'e', "enum-option", "this is an enum option."); - EXPECT_THROW(parser.parse(), seqan3::user_input_error); + EXPECT_THROW(parser.parse(), sharg::user_input_error); } // https://github.com/seqan/seqan3/issues/2464 @@ -1038,43 +1038,43 @@ TEST(parse_test, issue2464) option_t option_value{}; - seqan3::argument_parser parser{"test_parser", 3, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 3, argv, sharg::update_notifications::off}; parser.add_option(option_value, 'e', "enum-option", "this is an enum option."); - EXPECT_THROW(parser.parse(), seqan3::user_input_error); + EXPECT_THROW(parser.parse(), sharg::user_input_error); } { const char * argv[] = {"./argument_parser_test", "-e", "one", "-e", "nine"}; std::vector option_values{}; - seqan3::argument_parser parser{"test_parser", 5, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 5, argv, sharg::update_notifications::off}; parser.add_option(option_values, 'e', "enum-option", "this is an enum option."); - EXPECT_THROW(parser.parse(), seqan3::user_input_error); + EXPECT_THROW(parser.parse(), sharg::user_input_error); } // Invalid inputs for enums are handled before any validator is evaluated. - // Thus the exception will be seqan3::user_input_error and not seqan3::validation_error. + // Thus the exception will be sharg::user_input_error and not sharg::validation_error. { const char * argv[] = {"./argument_parser_test", "-e", "nine"}; - seqan3::value_list_validator enum_validator{(seqan3::enumeration_names | std::views::values)}; + sharg::value_list_validator enum_validator{(sharg::enumeration_names | std::views::values)}; option_t option_value{}; - seqan3::argument_parser parser{"test_parser", 3, argv, seqan3::update_notifications::off}; - parser.add_option(option_value, 'e', "enum-option", "this is an enum option.", seqan3::option_spec::advanced, + sharg::argument_parser parser{"test_parser", 3, argv, sharg::update_notifications::off}; + parser.add_option(option_value, 'e', "enum-option", "this is an enum option.", sharg::option_spec::advanced, enum_validator); - EXPECT_THROW(parser.parse(), seqan3::user_input_error); + EXPECT_THROW(parser.parse(), sharg::user_input_error); } { const char * argv[] = {"./argument_parser_test", "-e", "one", "-e", "nine"}; - seqan3::value_list_validator enum_validator{(seqan3::enumeration_names | std::views::values)}; + sharg::value_list_validator enum_validator{(sharg::enumeration_names | std::views::values)}; std::vector option_values{}; - seqan3::argument_parser parser{"test_parser", 5, argv, seqan3::update_notifications::off}; - parser.add_option(option_values, 'e', "enum-option", "this is an enum option.", seqan3::option_spec::advanced, + sharg::argument_parser parser{"test_parser", 5, argv, sharg::update_notifications::off}; + parser.add_option(option_values, 'e', "enum-option", "this is an enum option.", sharg::option_spec::advanced, enum_validator); - EXPECT_THROW(parser.parse(), seqan3::user_input_error); + EXPECT_THROW(parser.parse(), sharg::user_input_error); } } @@ -1086,7 +1086,7 @@ TEST(parse_test, enum_error_message) foo::bar option_value{}; - seqan3::argument_parser parser{"test_parser", 3, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 3, argv, sharg::update_notifications::off}; parser.add_option(option_value, 'e', "enum-option", "this is an enum option."); std::string expected_message{"You have chosen an invalid input value: nine. " @@ -1097,7 +1097,7 @@ TEST(parse_test, enum_error_message) parser.parse(); FAIL(); } - catch (seqan3::user_input_error const & exception) + catch (sharg::user_input_error const & exception) { EXPECT_EQ(expected_message, exception.what()); } @@ -1112,7 +1112,7 @@ TEST(parse_test, enum_error_message) Other::bar option_value{}; - seqan3::argument_parser parser{"test_parser", 3, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 3, argv, sharg::update_notifications::off}; parser.add_option(option_value, 'e', "enum-option", "this is an enum option."); std::string expected_message{"You have chosen an invalid input value: nine. " @@ -1123,7 +1123,7 @@ TEST(parse_test, enum_error_message) parser.parse(); FAIL(); } - catch (seqan3::user_input_error const & exception) + catch (sharg::user_input_error const & exception) { EXPECT_EQ(expected_message, exception.what()); } @@ -1141,7 +1141,7 @@ TEST(parse_test, error_message_parsing) uint64_t option_value{}; - seqan3::argument_parser parser{"test_parser", 3, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 3, argv, sharg::update_notifications::off}; parser.add_option(option_value, '\0', "value", "Please specify a value."); std::string expected_message{"Value parse failed for --value: Argument -30 could not be parsed as type " @@ -1152,7 +1152,7 @@ TEST(parse_test, error_message_parsing) parser.parse(); FAIL(); } - catch (seqan3::user_input_error const & exception) + catch (sharg::user_input_error const & exception) { EXPECT_EQ(expected_message, exception.what()); } @@ -1169,7 +1169,7 @@ TEST(parse_test, container_options) std::vector option_values{}; const char * argv[] = {"./argument_parser_test", "-e", "two", "-e", "one", "-e", "three"}; - seqan3::argument_parser parser{"test_parser", 7, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 7, argv, sharg::update_notifications::off}; parser.add_option(option_values, 'e', "enum-option", "this is an enum option."); EXPECT_NO_THROW(parser.parse()); @@ -1181,7 +1181,7 @@ TEST(parse_test, container_options) std::vector option_values{}; const char * argv[] = {"./argument_parser_test", "-i", "2", "-i", "1", "-i", "3"}; - seqan3::argument_parser parser{"test_parser", 7, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 7, argv, sharg::update_notifications::off}; parser.add_option(option_values, 'i', "int-option", "this is an int option."); EXPECT_NO_THROW(parser.parse()); @@ -1193,7 +1193,7 @@ TEST(parse_test, container_options) std::vector option_values{}; const char * argv[] = {"./argument_parser_test", "-b", "true", "-b", "false", "-b", "true"}; - seqan3::argument_parser parser{"test_parser", 7, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 7, argv, sharg::update_notifications::off}; parser.add_option(option_values, 'b', "bool-option", "this is a bool option."); EXPECT_NO_THROW(parser.parse()); @@ -1210,7 +1210,7 @@ TEST(parse_test, container_default) std::vector option_values{1, 2, 3}; const char * argv[] = {"./argument_parser_test", "-i", "2", "-i", "1", "-i", "3"}; - seqan3::argument_parser parser{"test_parser", 7, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 7, argv, sharg::update_notifications::off}; parser.add_option(option_values, 'i', "int-option", "this is an int option."); EXPECT_NO_THROW(parser.parse()); @@ -1223,7 +1223,7 @@ TEST(parse_test, container_default) bool bool_opt{false}; const char * argv[] = {"./argument_parser_test", "-i", "2", "-b", "true", "-i", "1", "-i", "3"}; - seqan3::argument_parser parser{"test_parser", 9, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 9, argv, sharg::update_notifications::off}; parser.add_option(option_values, 'i', "int-option", "this is an int option."); parser.add_option(bool_opt, 'b', "bool-option", "this is a bool option."); @@ -1237,7 +1237,7 @@ TEST(parse_test, container_default) bool bool_opt{false}; const char * argv[] = {"./argument_parser_test", "-b", "true"}; - seqan3::argument_parser parser{"test_parser", 3, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 3, argv, sharg::update_notifications::off}; parser.add_option(option_values, 'i', "int-option", "this is an int option."); parser.add_option(bool_opt, 'b', "bool-option", "this is a bool option."); @@ -1250,7 +1250,7 @@ TEST(parse_test, container_default) std::vector option_values{1, 2, 3}; const char * argv[] = {"./argument_parser_test", "2", "1", "3"}; - seqan3::argument_parser parser{"test_parser", 4, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 4, argv, sharg::update_notifications::off}; parser.add_positional_option(option_values, "this is an int option."); EXPECT_NO_THROW(parser.parse()); diff --git a/test/unit/format_parse_validators_test.cpp b/test/unit/format_parse_validators_test.cpp index ff0dbcdb..f2a3073d 100644 --- a/test/unit/format_parse_validators_test.cpp +++ b/test/unit/format_parse_validators_test.cpp @@ -2,7 +2,7 @@ // Copyright (c) 2006-2021, Knut Reinert & Freie Universität Berlin // Copyright (c) 2016-2021, Knut Reinert & MPI für molekulare Genetik // This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License -// shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md +// shipped with this file and also available at: https://github.com/seqan/sharg-parser/blob/master/LICENSE.md // ----------------------------------------------------------------------------------------------------- #include @@ -48,18 +48,18 @@ std::string const basic_options_str = "OPTIONS\n" std::string const basic_version_str = "VERSION\n" " Last update:\n" " test_parser version:\n" - " SeqAn version: " + std::string{seqan3::seqan3_version_cstring} + "\n"; + " SeqAn version: " + std::string{sharg::sharg_version_cstring} + "\n"; namespace seqan3::detail { struct test_accessor { - static void set_terminal_width(seqan3::argument_parser & parser, unsigned terminal_width) + static void set_terminal_width(sharg::argument_parser & parser, unsigned terminal_width) { std::visit([terminal_width](auto & f) { - if constexpr(std::is_same_v) - f.layout = seqan3::detail::format_help::console_layout_struct{terminal_width}; + if constexpr(std::is_same_v) + f.layout = sharg::detail::format_help::console_layout_struct{terminal_width}; }, parser.format); } }; @@ -69,23 +69,23 @@ using seqan3::detail::test_accessor; TEST(validator_test, fullfill_concept) { - EXPECT_FALSE(seqan3::validator); - - EXPECT_TRUE(seqan3::validator>); - EXPECT_TRUE(seqan3::validator const>); - EXPECT_TRUE(seqan3::validator &>); - - EXPECT_TRUE(seqan3::validator>>); - EXPECT_TRUE(seqan3::validator>); - EXPECT_TRUE(seqan3::validator>); - EXPECT_TRUE(seqan3::validator>); - EXPECT_TRUE(seqan3::validator>); - EXPECT_TRUE(seqan3::validator>); - EXPECT_TRUE(seqan3::validator); - EXPECT_TRUE(seqan3::validator); - EXPECT_TRUE(seqan3::validator); - - EXPECT_TRUE(seqan3::validator); + EXPECT_FALSE(sharg::validator); + + EXPECT_TRUE(sharg::validator>); + EXPECT_TRUE(sharg::validator const>); + EXPECT_TRUE(sharg::validator &>); + + EXPECT_TRUE(sharg::validator>>); + EXPECT_TRUE(sharg::validator>); + EXPECT_TRUE(sharg::validator>); + EXPECT_TRUE(sharg::validator>); + EXPECT_TRUE(sharg::validator>); + EXPECT_TRUE(sharg::validator>); + EXPECT_TRUE(sharg::validator); + EXPECT_TRUE(sharg::validator); + EXPECT_TRUE(sharg::validator); + + EXPECT_TRUE(sharg::validator); } TEST(validator_test, input_file) @@ -105,41 +105,41 @@ TEST(validator_test, input_file) { // single file { // empty list of file. - seqan3::input_file_validator my_validator{}; + sharg::input_file_validator my_validator{}; EXPECT_NO_THROW(my_validator(tmp_name.get_path())); } { // file already exists. std::filesystem::path does_not_exist{tmp_name.get_path()}; does_not_exist.replace_extension(".bam"); - seqan3::input_file_validator my_validator{formats}; - EXPECT_THROW(my_validator(does_not_exist), seqan3::validation_error); + sharg::input_file_validator my_validator{formats}; + EXPECT_THROW(my_validator(does_not_exist), sharg::validation_error); } { // file has wrong format. - seqan3::input_file_validator my_validator{std::vector{std::string{"sam"}}}; - EXPECT_THROW(my_validator(tmp_name.get_path()), seqan3::validation_error); + sharg::input_file_validator my_validator{std::vector{std::string{"sam"}}}; + EXPECT_THROW(my_validator(tmp_name.get_path()), sharg::validation_error); } { // file has no extension. std::filesystem::path does_not_exist{tmp_name.get_path()}; does_not_exist.replace_extension(); - seqan3::input_file_validator my_validator{formats}; - EXPECT_THROW(my_validator(does_not_exist), seqan3::validation_error); + sharg::input_file_validator my_validator{formats}; + EXPECT_THROW(my_validator(does_not_exist), sharg::validation_error); } { // filename starts with dot. - seqan3::input_file_validator my_validator{formats}; + sharg::input_file_validator my_validator{formats}; EXPECT_NO_THROW(my_validator(tmp_name_hidden.get_path())); } { // file has multiple extensions. - seqan3::input_file_validator my_validator{formats}; + sharg::input_file_validator my_validator{formats}; EXPECT_NO_THROW(my_validator(tmp_name_multiple.get_path())); } { // read from file - seqan3::input_file_validator my_validator{}; + sharg::input_file_validator my_validator{}; EXPECT_NO_THROW(my_validator(tmp_name.get_path())); } @@ -148,10 +148,10 @@ TEST(validator_test, input_file) // option std::string const & path = tmp_name.get_path().string(); const char * argv[] = {"./argument_parser_test", "-i", path.c_str()}; - seqan3::argument_parser parser{"test_parser", 3, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 3, argv, sharg::update_notifications::off}; test_accessor::set_terminal_width(parser, 80); parser.add_option(file_in_path, 'i', "int-option", "desc", - seqan3::option_spec::standard, seqan3::input_file_validator{formats}); + sharg::option_spec::standard, sharg::input_file_validator{formats}); EXPECT_NO_THROW(parser.parse()); EXPECT_EQ(file_in_path.string(), path); @@ -165,9 +165,9 @@ TEST(validator_test, input_file) std::string const & path_2 = tmp_name_2.get_path().string(); const char * argv[] = {"./argument_parser_test", path.c_str(), path_2.c_str()}; - seqan3::argument_parser parser{"test_parser", 3, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 3, argv, sharg::update_notifications::off}; test_accessor::set_terminal_width(parser, 80); - parser.add_positional_option(input_files, "desc", seqan3::input_file_validator{formats}); + parser.add_positional_option(input_files, "desc", sharg::input_file_validator{formats}); EXPECT_NO_THROW(parser.parse()); EXPECT_EQ(input_files.size(), 2u); @@ -178,9 +178,9 @@ TEST(validator_test, input_file) { // get help page message std::filesystem::path path; const char * argv[] = {"./argument_parser_test", "-h"}; - seqan3::argument_parser parser{"test_parser", 2, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 2, argv, sharg::update_notifications::off}; test_accessor::set_terminal_width(parser, 80); - parser.add_positional_option(path, "desc", seqan3::input_file_validator{formats}); + parser.add_positional_option(path, "desc", sharg::input_file_validator{formats}); testing::internal::CaptureStdout(); EXPECT_EXIT(parser.parse(), ::testing::ExitedWithCode(EXIT_SUCCESS), ""); @@ -203,11 +203,11 @@ TEST(validator_test, input_file) TEST(validator_test, input_file_ext_from_file) { // Give as a template argument the seqan3 file type to get all valid extensions for this file. - seqan3::input_file_validator validator{}; + sharg::input_file_validator validator{}; EXPECT_EQ(validator.get_help_page_message(), "The input file must exist and read permissions must be granted. " "Valid file extensions are: [fa, fasta, sam, bam]."); - seqan3::input_file_validator validator2{}; + sharg::input_file_validator validator2{}; EXPECT_EQ(validator2.get_help_page_message(), "The input file must exist and read permissions must be granted."); } @@ -226,51 +226,51 @@ TEST(validator_test, output_file) { // single file { // file does not exist (& no formats given) - seqan3::output_file_validator my_validator{seqan3::output_file_open_options::open_or_create}; + sharg::output_file_validator my_validator{sharg::output_file_open_options::open_or_create}; EXPECT_NO_THROW(my_validator(not_existing_path)); - seqan3::output_file_validator my_validator2{seqan3::output_file_open_options::create_new}; + sharg::output_file_validator my_validator2{sharg::output_file_open_options::create_new}; EXPECT_NO_THROW(my_validator2(not_existing_path)); - seqan3::output_file_validator my_validator3{}; // default: create_new + sharg::output_file_validator my_validator3{}; // default: create_new EXPECT_NO_THROW(my_validator3(not_existing_path)); } { // file does exist & overwriting is prohibited - seqan3::output_file_validator my_validator{seqan3::output_file_open_options::create_new, formats}; - EXPECT_THROW(my_validator(existing_path), seqan3::validation_error); + sharg::output_file_validator my_validator{sharg::output_file_open_options::create_new, formats}; + EXPECT_THROW(my_validator(existing_path), sharg::validation_error); } { // file does exist but allow to overwrite it - seqan3::output_file_validator my_validator{seqan3::output_file_open_options::open_or_create, formats}; + sharg::output_file_validator my_validator{sharg::output_file_open_options::open_or_create, formats}; EXPECT_NO_THROW(my_validator(existing_path)); } { // file has wrong format. - seqan3::output_file_validator my_validator{seqan3::output_file_open_options::create_new, + sharg::output_file_validator my_validator{sharg::output_file_open_options::create_new, std::vector{std::string{"sam"}}}; - EXPECT_THROW(my_validator(tmp_name.get_path()), seqan3::validation_error); + EXPECT_THROW(my_validator(tmp_name.get_path()), sharg::validation_error); } { // file has no extension. std::filesystem::path no_extension{tmp_name.get_path()}; no_extension.replace_extension(); - seqan3::output_file_validator my_validator{seqan3::output_file_open_options::create_new, formats}; - EXPECT_THROW(my_validator(no_extension), seqan3::validation_error); + sharg::output_file_validator my_validator{sharg::output_file_open_options::create_new, formats}; + EXPECT_THROW(my_validator(no_extension), sharg::validation_error); } { // filename starts with dot. - seqan3::output_file_validator my_validator{seqan3::output_file_open_options::create_new, formats}; + sharg::output_file_validator my_validator{sharg::output_file_open_options::create_new, formats}; EXPECT_NO_THROW(my_validator(hidden_name.get_path())); } { // file has multiple extensions. std::filesystem::path multiple_extension{tmp_name.get_path()}; multiple_extension.replace_extension("fasta.txt"); - seqan3::output_file_validator my_validator{seqan3::output_file_open_options::create_new, formats}; + sharg::output_file_validator my_validator{sharg::output_file_open_options::create_new, formats}; EXPECT_NO_THROW(my_validator(multiple_extension)); } { // read from file - seqan3::output_file_validator my_validator{}; + sharg::output_file_validator my_validator{}; EXPECT_NO_THROW(my_validator(tmp_name.get_path())); } @@ -279,11 +279,11 @@ TEST(validator_test, output_file) // option std::string const & path = tmp_name.get_path().string(); const char * argv[] = {"./argument_parser_test", "-o", path.c_str()}; - seqan3::argument_parser parser{"test_parser", 3, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 3, argv, sharg::update_notifications::off}; test_accessor::set_terminal_width(parser, 80); parser.add_option(file_out_path, 'o', "out-option", "desc", - seqan3::option_spec::standard, - seqan3::output_file_validator{seqan3::output_file_open_options::create_new, formats}); + sharg::option_spec::standard, + sharg::output_file_validator{sharg::output_file_open_options::create_new, formats}); EXPECT_NO_THROW(parser.parse()); EXPECT_EQ(file_out_path.string(), path); @@ -297,10 +297,10 @@ TEST(validator_test, output_file) std::string const & path_3 = tmp_name_3.get_path().string(); const char * argv[] = {"./argument_parser_test", path.c_str(), path_3.c_str()}; - seqan3::argument_parser parser{"test_parser", 3, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 3, argv, sharg::update_notifications::off}; test_accessor::set_terminal_width(parser, 80); parser.add_positional_option(output_files, "desc", - seqan3::output_file_validator{seqan3::output_file_open_options::create_new, formats}); + sharg::output_file_validator{sharg::output_file_open_options::create_new, formats}); EXPECT_NO_THROW(parser.parse()); EXPECT_EQ(output_files.size(), 2u); @@ -312,10 +312,10 @@ TEST(validator_test, output_file) { std::filesystem::path path; const char * argv[] = {"./argument_parser_test", "-h"}; - seqan3::argument_parser parser{"test_parser", 2, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 2, argv, sharg::update_notifications::off}; test_accessor::set_terminal_width(parser, 80); parser.add_positional_option(path, "desc", - seqan3::output_file_validator{seqan3::output_file_open_options::create_new, formats}); + sharg::output_file_validator{sharg::output_file_open_options::create_new, formats}); testing::internal::CaptureStdout(); EXPECT_EXIT(parser.parse(), ::testing::ExitedWithCode(EXIT_SUCCESS), ""); @@ -339,10 +339,10 @@ TEST(validator_test, output_file) { std::filesystem::path path; const char * argv[] = {"./argument_parser_test", "-h"}; - seqan3::argument_parser parser{"test_parser", 2, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 2, argv, sharg::update_notifications::off}; test_accessor::set_terminal_width(parser, 80); parser.add_positional_option(path, "desc", - seqan3::output_file_validator{seqan3::output_file_open_options::open_or_create, + sharg::output_file_validator{sharg::output_file_open_options::open_or_create, formats}); testing::internal::CaptureStdout(); @@ -366,27 +366,27 @@ TEST(validator_test, output_file) TEST(validator_test, output_file_ext_from_file) { // Give as a template argument the seqan3 file type to get all valid extensions for this file. - seqan3::output_file_validator validator1{}; + sharg::output_file_validator validator1{}; EXPECT_EQ(validator1.get_help_page_message(), "The output file must not exist already and write permissions must " "be granted. Valid file extensions are: [fa, fasta, sam, bam]."); - seqan3::output_file_validator validator2{seqan3::output_file_open_options::create_new}; + sharg::output_file_validator validator2{sharg::output_file_open_options::create_new}; EXPECT_EQ(validator2.get_help_page_message(), "The output file must not exist already and write permissions must " "be granted. Valid file extensions are: [fa, fasta, sam, bam]."); - seqan3::output_file_validator validator3{seqan3::output_file_open_options::open_or_create}; + sharg::output_file_validator validator3{sharg::output_file_open_options::open_or_create}; EXPECT_EQ(validator3.get_help_page_message(), "Write permissions must be granted. Valid file extensions are: [fa, " "fasta, sam, bam]."); - seqan3::output_file_validator validator4{}; + sharg::output_file_validator validator4{}; EXPECT_EQ(validator4.get_help_page_message(), "The output file must not exist already and write permissions must " "be granted."); - seqan3::output_file_validator validator5{seqan3::output_file_open_options::create_new}; + sharg::output_file_validator validator5{sharg::output_file_open_options::create_new}; EXPECT_EQ(validator5.get_help_page_message(), "The output file must not exist already and write permissions must " "be granted."); - seqan3::output_file_validator validator6{seqan3::output_file_open_options::open_or_create}; + sharg::output_file_validator validator6{sharg::output_file_open_options::open_or_create}; EXPECT_EQ(validator6.get_help_page_message(), "Write permissions must be granted."); } @@ -398,15 +398,15 @@ TEST(validator_test, input_directory) { // has filename std::ofstream tmp_dir(tmp_name.get_path()); - seqan3::input_directory_validator my_validator{}; - EXPECT_THROW(my_validator(tmp_name.get_path()), seqan3::validation_error); + sharg::input_directory_validator my_validator{}; + EXPECT_THROW(my_validator(tmp_name.get_path()), sharg::validation_error); } { // read directory std::filesystem::path p = tmp_name.get_path(); p.remove_filename(); std::ofstream tmp_dir(p); - seqan3::input_directory_validator my_validator{}; + sharg::input_directory_validator my_validator{}; my_validator(p); EXPECT_NO_THROW(my_validator(p)); @@ -415,10 +415,10 @@ TEST(validator_test, input_directory) // option std::string const & path = p.string(); const char * argv[] = {"./argument_parser_test", "-i", path.c_str()}; - seqan3::argument_parser parser{"test_parser", 3, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 3, argv, sharg::update_notifications::off}; test_accessor::set_terminal_width(parser, 80); parser.add_option(dir_in_path, 'i', "input-option", "desc", - seqan3::option_spec::standard, seqan3::input_directory_validator{}); + sharg::option_spec::standard, sharg::input_directory_validator{}); EXPECT_NO_THROW(parser.parse()); EXPECT_EQ(path, dir_in_path.string()); @@ -429,9 +429,9 @@ TEST(validator_test, input_directory) // get help page message std::filesystem::path path; const char * argv[] = {"./argument_parser_test", "-h"}; - seqan3::argument_parser parser{"test_parser", 2, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 2, argv, sharg::update_notifications::off}; test_accessor::set_terminal_width(parser, 80); - parser.add_positional_option(path, "desc", seqan3::input_directory_validator{}); + parser.add_positional_option(path, "desc", sharg::input_directory_validator{}); testing::internal::CaptureStdout(); EXPECT_EXIT(parser.parse(), ::testing::ExitedWithCode(EXIT_SUCCESS), ""); @@ -458,7 +458,7 @@ TEST(validator_test, output_directory) { // read directory std::filesystem::path p = tmp_name.get_path(); p.remove_filename(); - seqan3::output_directory_validator my_validator{}; + sharg::output_directory_validator my_validator{}; my_validator(p); EXPECT_NO_THROW(); @@ -467,11 +467,11 @@ TEST(validator_test, output_directory) // option std::string const & path = p.string(); const char * argv[] = {"./argument_parser_test", "-o", path.c_str()}; - seqan3::argument_parser parser{"test_parser", 3, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 3, argv, sharg::update_notifications::off}; test_accessor::set_terminal_width(parser, 80); parser.add_option(dir_out_path, 'o', "output-option", "desc", - seqan3::option_spec::standard, - seqan3::output_directory_validator{}); + sharg::option_spec::standard, + sharg::output_directory_validator{}); EXPECT_NO_THROW(parser.parse()); EXPECT_EQ(path, dir_out_path.string()); @@ -485,16 +485,16 @@ TEST(validator_test, output_directory) std::filesystem::create_directory(tmp_parent_path); EXPECT_TRUE(std::filesystem::exists(tmp_parent_path)); - EXPECT_NO_THROW(seqan3::output_directory_validator{}(tmp_child_dir)); + EXPECT_NO_THROW(sharg::output_directory_validator{}(tmp_child_dir)); } { // get help page message std::filesystem::path path; const char * argv[] = {"./argument_parser_test", "-h"}; - seqan3::argument_parser parser{"test_parser", 2, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 2, argv, sharg::update_notifications::off}; test_accessor::set_terminal_width(parser, 80); - parser.add_positional_option(path, "desc", seqan3::output_directory_validator{}); + parser.add_positional_option(path, "desc", sharg::output_directory_validator{}); testing::internal::CaptureStdout(); EXPECT_EXIT(parser.parse(), ::testing::ExitedWithCode(EXIT_SUCCESS), ""); @@ -520,7 +520,7 @@ TEST(validator_test, inputfile_not_readable) std::filesystem::path tmp_file{tmp_name.get_path()}; std::ofstream str{tmp_name.get_path()}; - EXPECT_NO_THROW(seqan3::input_file_validator{}(tmp_file)); + EXPECT_NO_THROW(sharg::input_file_validator{}(tmp_file)); std::filesystem::permissions(tmp_file, std::filesystem::perms::owner_read | std::filesystem::perms::group_read | @@ -529,7 +529,7 @@ TEST(validator_test, inputfile_not_readable) if (!seqan3::test::read_access(tmp_file)) // Do not execute with root permissions. { - EXPECT_THROW(seqan3::input_file_validator{}(tmp_file), seqan3::validation_error); + EXPECT_THROW(sharg::input_file_validator{}(tmp_file), sharg::validation_error); } std::filesystem::permissions(tmp_file, @@ -544,7 +544,7 @@ TEST(validator_test, inputfile_not_regular) std::filesystem::path filename = tmp.get_path(); mkfifo(filename.c_str(), 0644); - EXPECT_THROW(seqan3::input_file_validator{}(filename), seqan3::validation_error); + EXPECT_THROW(sharg::input_file_validator{}(filename), sharg::validation_error); } TEST(validator_test, inputdir_not_existing) @@ -552,7 +552,7 @@ TEST(validator_test, inputdir_not_existing) seqan3::test::tmp_filename tmp_name{"dir"}; std::filesystem::path not_existing_dir{tmp_name.get_path()}; - EXPECT_THROW(seqan3::input_directory_validator{}(not_existing_dir), seqan3::validation_error); + EXPECT_THROW(sharg::input_directory_validator{}(not_existing_dir), sharg::validation_error); } TEST(validator_test, inputdir_not_readable) @@ -562,7 +562,7 @@ TEST(validator_test, inputdir_not_readable) std::filesystem::create_directory(tmp_dir); - EXPECT_NO_THROW(seqan3::input_directory_validator{}(tmp_dir)); + EXPECT_NO_THROW(sharg::input_directory_validator{}(tmp_dir)); std::filesystem::permissions(tmp_dir, std::filesystem::perms::owner_read | std::filesystem::perms::group_read | @@ -571,7 +571,7 @@ TEST(validator_test, inputdir_not_readable) if (!seqan3::test::read_access(tmp_dir)) // Do not execute with root permissions. { - EXPECT_THROW(seqan3::input_directory_validator{}(tmp_dir), seqan3::validation_error); + EXPECT_THROW(sharg::input_directory_validator{}(tmp_dir), sharg::validation_error); } std::filesystem::permissions(tmp_dir, @@ -585,7 +585,7 @@ TEST(validator_test, outputfile_not_writable) seqan3::test::tmp_filename tmp_name{"my_file.test"}; std::filesystem::path tmp_file{tmp_name.get_path()}; - EXPECT_NO_THROW(seqan3::output_file_validator{seqan3::output_file_open_options::create_new}(tmp_file)); + EXPECT_NO_THROW(sharg::output_file_validator{sharg::output_file_open_options::create_new}(tmp_file)); // Parent path is not writable. std::filesystem::permissions(tmp_file.parent_path(), @@ -595,8 +595,8 @@ TEST(validator_test, outputfile_not_writable) if (!seqan3::test::write_access(tmp_file)) // Do not execute with root permissions. { - EXPECT_THROW(seqan3::output_file_validator{seqan3::output_file_open_options::create_new}(tmp_file), - seqan3::validation_error); + EXPECT_THROW(sharg::output_file_validator{sharg::output_file_open_options::create_new}(tmp_file), + sharg::validation_error); } // make sure we can remove the directory. @@ -612,7 +612,7 @@ TEST(validator_test, outputdir_not_writable) seqan3::test::tmp_filename tmp_name{"dir"}; std::filesystem::path tmp_dir{tmp_name.get_path()}; - EXPECT_NO_THROW(seqan3::output_file_validator{seqan3::output_file_open_options::create_new}(tmp_dir)); + EXPECT_NO_THROW(sharg::output_file_validator{sharg::output_file_open_options::create_new}(tmp_dir)); EXPECT_FALSE(std::filesystem::exists(tmp_dir)); // parent dir does not exist @@ -620,7 +620,7 @@ TEST(validator_test, outputdir_not_writable) std::filesystem::path tmp_child_dir{tmp_child_name.get_path()}; std::filesystem::path tmp_parent_dir{tmp_child_dir.parent_path()}; - EXPECT_THROW(seqan3::output_directory_validator{}(tmp_child_dir), seqan3::validation_error); + EXPECT_THROW(sharg::output_directory_validator{}(tmp_child_dir), sharg::validation_error); // Directory exists but is not writable. std::filesystem::create_directory(tmp_dir); @@ -632,7 +632,7 @@ TEST(validator_test, outputdir_not_writable) EXPECT_TRUE(std::filesystem::exists(tmp_dir)); if (!seqan3::test::write_access(tmp_dir)) // Do not execute with root permissions. { - EXPECT_THROW(seqan3::output_directory_validator{}(tmp_dir), seqan3::validation_error); + EXPECT_THROW(sharg::output_directory_validator{}(tmp_dir), sharg::validation_error); } // Parent path is not writable. @@ -643,8 +643,8 @@ TEST(validator_test, outputdir_not_writable) if (!seqan3::test::write_access(tmp_dir)) // Do not execute with root permissions. { - EXPECT_THROW(seqan3::output_file_validator{seqan3::output_file_open_options::create_new}(tmp_dir), - seqan3::validation_error); + EXPECT_THROW(sharg::output_file_validator{sharg::output_file_open_options::create_new}(tmp_dir), + sharg::validation_error); } // make sure we can remove the directories. @@ -663,7 +663,7 @@ TEST(validator_test, outputdir_not_writable) std::filesystem::path tmp_dir{tmp_name.get_path()}; std::filesystem::create_directory(tmp_dir); - EXPECT_NO_THROW(seqan3::output_directory_validator{}(tmp_dir)); + EXPECT_NO_THROW(sharg::output_directory_validator{}(tmp_dir)); // This path exists but is not writable. std::filesystem::permissions(tmp_dir, @@ -673,8 +673,8 @@ TEST(validator_test, outputdir_not_writable) if (!seqan3::test::write_access(tmp_dir)) // Do not execute with root permissions. { - EXPECT_THROW(seqan3::output_file_validator{seqan3::output_file_open_options::create_new}(tmp_dir), - seqan3::validation_error); + EXPECT_THROW(sharg::output_file_validator{sharg::output_file_open_options::create_new}(tmp_dir), + sharg::validation_error); } // make sure we can remove the directory. @@ -692,10 +692,10 @@ TEST(validator_test, arithmetic_range_validator_success) // option const char * argv[] = {"./argument_parser_test", "-i", "10"}; - seqan3::argument_parser parser{"test_parser", 3, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 3, argv, sharg::update_notifications::off}; test_accessor::set_terminal_width(parser, 80); parser.add_option(option_value, 'i', "int-option", "desc", - seqan3::option_spec::standard, seqan3::arithmetic_range_validator{1, 20}); + sharg::option_spec::standard, sharg::arithmetic_range_validator{1, 20}); testing::internal::CaptureStderr(); EXPECT_NO_THROW(parser.parse()); @@ -704,10 +704,10 @@ TEST(validator_test, arithmetic_range_validator_success) // option - negative values const char * argv2[] = {"./argument_parser_test", "-i", "-10"}; - seqan3::argument_parser parser2{"test_parser", 3, argv2, seqan3::update_notifications::off}; + sharg::argument_parser parser2{"test_parser", 3, argv2, sharg::update_notifications::off}; test_accessor::set_terminal_width(parser2, 80); parser2.add_option(option_value, 'i', "int-option", "desc", - seqan3::option_spec::standard, seqan3::arithmetic_range_validator{-20, 20}); + sharg::option_spec::standard, sharg::arithmetic_range_validator{-20, 20}); testing::internal::CaptureStderr(); EXPECT_NO_THROW(parser2.parse()); @@ -716,9 +716,9 @@ TEST(validator_test, arithmetic_range_validator_success) // positional option const char * argv3[] = {"./argument_parser_test", "10"}; - seqan3::argument_parser parser3{"test_parser", 2, argv3, seqan3::update_notifications::off}; + sharg::argument_parser parser3{"test_parser", 2, argv3, sharg::update_notifications::off}; test_accessor::set_terminal_width(parser3, 80); - parser3.add_positional_option(option_value, "desc", seqan3::arithmetic_range_validator{1, 20}); + parser3.add_positional_option(option_value, "desc", sharg::arithmetic_range_validator{1, 20}); testing::internal::CaptureStderr(); EXPECT_NO_THROW(parser3.parse()); @@ -727,9 +727,9 @@ TEST(validator_test, arithmetic_range_validator_success) // positional option - negative values const char * argv4[] = {"./argument_parser_test", "--", "-10"}; - seqan3::argument_parser parser4{"test_parser", 3, argv4, seqan3::update_notifications::off}; + sharg::argument_parser parser4{"test_parser", 3, argv4, sharg::update_notifications::off}; test_accessor::set_terminal_width(parser4, 80); - parser4.add_positional_option(option_value, "desc", seqan3::arithmetic_range_validator{-20, 20}); + parser4.add_positional_option(option_value, "desc", sharg::arithmetic_range_validator{-20, 20}); testing::internal::CaptureStderr(); EXPECT_NO_THROW(parser4.parse()); @@ -738,10 +738,10 @@ TEST(validator_test, arithmetic_range_validator_success) // option - vector const char * argv5[] = {"./argument_parser_test", "-i", "-10", "-i", "48"}; - seqan3::argument_parser parser5{"test_parser", 5, argv5, seqan3::update_notifications::off}; + sharg::argument_parser parser5{"test_parser", 5, argv5, sharg::update_notifications::off}; test_accessor::set_terminal_width(parser5, 80); parser5.add_option(option_vector, 'i', "int-option", "desc", - seqan3::option_spec::standard, seqan3::arithmetic_range_validator{-50,50}); + sharg::option_spec::standard, sharg::arithmetic_range_validator{-50,50}); testing::internal::CaptureStderr(); EXPECT_NO_THROW(parser5.parse()); @@ -752,9 +752,9 @@ TEST(validator_test, arithmetic_range_validator_success) // positional option - vector option_vector.clear(); const char * argv6[] = {"./argument_parser_test", "--", "-10", "1"}; - seqan3::argument_parser parser6{"test_parser", 4, argv6, seqan3::update_notifications::off}; + sharg::argument_parser parser6{"test_parser", 4, argv6, sharg::update_notifications::off}; test_accessor::set_terminal_width(parser6, 80); - parser6.add_positional_option(option_vector, "desc", seqan3::arithmetic_range_validator{-20,20}); + parser6.add_positional_option(option_vector, "desc", sharg::arithmetic_range_validator{-20,20}); testing::internal::CaptureStderr(); EXPECT_NO_THROW(parser6.parse()); @@ -765,9 +765,9 @@ TEST(validator_test, arithmetic_range_validator_success) // get help page message option_vector.clear(); const char * argv7[] = {"./argument_parser_test", "-h"}; - seqan3::argument_parser parser7{"test_parser", 2, argv7, seqan3::update_notifications::off}; + sharg::argument_parser parser7{"test_parser", 2, argv7, sharg::update_notifications::off}; test_accessor::set_terminal_width(parser7, 80); - parser7.add_positional_option(option_vector, "desc", seqan3::arithmetic_range_validator{-20,20}); + parser7.add_positional_option(option_vector, "desc", sharg::arithmetic_range_validator{-20,20}); testing::internal::CaptureStdout(); EXPECT_EXIT(parser7.parse(), ::testing::ExitedWithCode(EXIT_SUCCESS), ""); @@ -787,10 +787,10 @@ TEST(validator_test, arithmetic_range_validator_success) // option - double value double double_option_value; const char * argv8[] = {"./argument_parser_test", "-i", "10.9"}; - seqan3::argument_parser parser8{"test_parser", 3, argv8, seqan3::update_notifications::off}; + sharg::argument_parser parser8{"test_parser", 3, argv8, sharg::update_notifications::off}; test_accessor::set_terminal_width(parser8, 80); parser8.add_option(double_option_value, 'i', "double-option", "desc", - seqan3::option_spec::standard, seqan3::arithmetic_range_validator{1, 20}); + sharg::option_spec::standard, sharg::arithmetic_range_validator{1, 20}); testing::internal::CaptureStderr(); EXPECT_NO_THROW(parser8.parse()); @@ -805,65 +805,65 @@ TEST(validator_test, arithmetic_range_validator_error) // option - above max const char * argv[] = {"./argument_parser_test", "-i", "30"}; - seqan3::argument_parser parser{"test_parser", 3, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 3, argv, sharg::update_notifications::off}; test_accessor::set_terminal_width(parser, 80); parser.add_option(option_value, 'i', "int-option", "desc", - seqan3::option_spec::standard, seqan3::arithmetic_range_validator{1, 20}); + sharg::option_spec::standard, sharg::arithmetic_range_validator{1, 20}); - EXPECT_THROW(parser.parse(), seqan3::validation_error); + EXPECT_THROW(parser.parse(), sharg::validation_error); // option - below min const char * argv2[] = {"./argument_parser_test", "-i", "-21"}; - seqan3::argument_parser parser2{"test_parser", 3, argv2, seqan3::update_notifications::off}; + sharg::argument_parser parser2{"test_parser", 3, argv2, sharg::update_notifications::off}; test_accessor::set_terminal_width(parser2, 80); parser2.add_option(option_value, 'i', "int-option", "desc", - seqan3::option_spec::standard, seqan3::arithmetic_range_validator{-20, 20}); + sharg::option_spec::standard, sharg::arithmetic_range_validator{-20, 20}); - EXPECT_THROW(parser2.parse(), seqan3::validation_error); + EXPECT_THROW(parser2.parse(), sharg::validation_error); // positional option - above max const char * argv3[] = {"./argument_parser_test", "30"}; - seqan3::argument_parser parser3{"test_parser", 2, argv3, seqan3::update_notifications::off}; + sharg::argument_parser parser3{"test_parser", 2, argv3, sharg::update_notifications::off}; test_accessor::set_terminal_width(parser3, 80); - parser3.add_positional_option(option_value, "desc", seqan3::arithmetic_range_validator{1, 20}); + parser3.add_positional_option(option_value, "desc", sharg::arithmetic_range_validator{1, 20}); - EXPECT_THROW(parser3.parse(), seqan3::validation_error); + EXPECT_THROW(parser3.parse(), sharg::validation_error); // positional option - below min const char * argv4[] = {"./argument_parser_test", "--", "-21"}; - seqan3::argument_parser parser4{"test_parser", 3, argv4, seqan3::update_notifications::off}; + sharg::argument_parser parser4{"test_parser", 3, argv4, sharg::update_notifications::off}; test_accessor::set_terminal_width(parser4, 80); - parser4.add_positional_option(option_value, "desc", seqan3::arithmetic_range_validator{-20, 20}); + parser4.add_positional_option(option_value, "desc", sharg::arithmetic_range_validator{-20, 20}); - EXPECT_THROW(parser4.parse(), seqan3::validation_error); + EXPECT_THROW(parser4.parse(), sharg::validation_error); // option - vector const char * argv5[] = {"./argument_parser_test", "-i", "-100"}; - seqan3::argument_parser parser5{"test_parser", 3, argv5, seqan3::update_notifications::off}; + sharg::argument_parser parser5{"test_parser", 3, argv5, sharg::update_notifications::off}; test_accessor::set_terminal_width(parser5, 80); parser5.add_option(option_vector, 'i', "int-option", "desc", - seqan3::option_spec::standard, seqan3::arithmetic_range_validator{-50, 50}); + sharg::option_spec::standard, sharg::arithmetic_range_validator{-50, 50}); - EXPECT_THROW(parser5.parse(), seqan3::validation_error); + EXPECT_THROW(parser5.parse(), sharg::validation_error); // positional option - vector option_vector.clear(); const char * argv6[] = {"./argument_parser_test", "--", "-10", "100"}; - seqan3::argument_parser parser6{"test_parser", 4, argv6, seqan3::update_notifications::off}; + sharg::argument_parser parser6{"test_parser", 4, argv6, sharg::update_notifications::off}; test_accessor::set_terminal_width(parser6, 80); - parser6.add_positional_option(option_vector, "desc", seqan3::arithmetic_range_validator{-20, 20}); + parser6.add_positional_option(option_vector, "desc", sharg::arithmetic_range_validator{-20, 20}); - EXPECT_THROW(parser6.parse(), seqan3::validation_error); + EXPECT_THROW(parser6.parse(), sharg::validation_error); // option - double value double double_option_value; const char * argv7[] = {"./argument_parser_test", "-i", "0.9"}; - seqan3::argument_parser parser7{"test_parser", 3, argv7, seqan3::update_notifications::off}; + sharg::argument_parser parser7{"test_parser", 3, argv7, sharg::update_notifications::off}; test_accessor::set_terminal_width(parser7, 80); parser7.add_option(double_option_value, 'i', "double-option", "desc", - seqan3::option_spec::standard, seqan3::arithmetic_range_validator{1, 20}); + sharg::option_spec::standard, sharg::arithmetic_range_validator{1, 20}); - EXPECT_THROW(parser7.parse(), seqan3::validation_error); + EXPECT_THROW(parser7.parse(), sharg::validation_error); } enum class foo @@ -878,35 +878,35 @@ TEST(validator_test, value_list_validator_success) // type deduction // -------------- // all arithmetic types are deduced to their common type in order to easily allow chaining of arithmetic validators - EXPECT_TRUE((std::same_as, - decltype(seqan3::value_list_validator{1})>)); + EXPECT_TRUE((std::same_as, + decltype(sharg::value_list_validator{1})>)); // except char - EXPECT_TRUE((std::same_as, - decltype(seqan3::value_list_validator{'c'})>)); + EXPECT_TRUE((std::same_as, + decltype(sharg::value_list_validator{'c'})>)); // The same holds for a range of arithmetic types std::vector v{1, 2, 3}; - EXPECT_TRUE((std::same_as, - decltype(seqan3::value_list_validator{v})>)); - EXPECT_TRUE((std::same_as, - decltype(seqan3::value_list_validator{v | std::views::take(2)})>)); + EXPECT_TRUE((std::same_as, + decltype(sharg::value_list_validator{v})>)); + EXPECT_TRUE((std::same_as, + decltype(sharg::value_list_validator{v | std::views::take(2)})>)); std::vector v_char{'1', '2', '3'}; - EXPECT_TRUE((std::same_as, - decltype(seqan3::value_list_validator{v_char})>)); - EXPECT_TRUE((std::same_as, - decltype(seqan3::value_list_validator{v_char | std::views::take(2)})>)); + EXPECT_TRUE((std::same_as, + decltype(sharg::value_list_validator{v_char})>)); + EXPECT_TRUE((std::same_as, + decltype(sharg::value_list_validator{v_char | std::views::take(2)})>)); // const char * is deduced to std::string std::vector v2{"ha", "ba", "ma"}; - EXPECT_TRUE((std::same_as, - decltype(seqan3::value_list_validator{"ha"})>)); - EXPECT_TRUE((std::same_as, - decltype(seqan3::value_list_validator{"ha", "ba", "ma"})>)); - EXPECT_TRUE((std::same_as, - decltype(seqan3::value_list_validator{v2})>)); - EXPECT_TRUE((std::same_as, - decltype(seqan3::value_list_validator{v2 | std::views::take(2)})>)); + EXPECT_TRUE((std::same_as, + decltype(sharg::value_list_validator{"ha"})>)); + EXPECT_TRUE((std::same_as, + decltype(sharg::value_list_validator{"ha", "ba", "ma"})>)); + EXPECT_TRUE((std::same_as, + decltype(sharg::value_list_validator{v2})>)); + EXPECT_TRUE((std::same_as, + decltype(sharg::value_list_validator{v2 | std::views::take(2)})>)); // custom types are used as is - EXPECT_TRUE((std::same_as, - decltype(seqan3::value_list_validator{foo::one, foo::two})>)); + EXPECT_TRUE((std::same_as, + decltype(sharg::value_list_validator{foo::one, foo::two})>)); // usage // ----- @@ -918,11 +918,11 @@ TEST(validator_test, value_list_validator_success) // option std::vector valid_str_values{"ha", "ba", "ma"}; const char * argv[] = {"./argument_parser_test", "-s", "ba"}; - seqan3::argument_parser parser{"test_parser", 3, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 3, argv, sharg::update_notifications::off}; test_accessor::set_terminal_width(parser, 80); parser.add_option(option_value, 's', "string-option", "desc", - seqan3::option_spec::standard, - seqan3::value_list_validator{valid_str_values | std::views::take(2)}); + sharg::option_spec::standard, + sharg::value_list_validator{valid_str_values | std::views::take(2)}); testing::internal::CaptureStderr(); EXPECT_NO_THROW(parser.parse()); @@ -931,10 +931,10 @@ TEST(validator_test, value_list_validator_success) // option with integers const char * argv2[] = {"./argument_parser_test", "-i", "-21"}; - seqan3::argument_parser parser2{"test_parser", 3, argv2, seqan3::update_notifications::off}; + sharg::argument_parser parser2{"test_parser", 3, argv2, sharg::update_notifications::off}; test_accessor::set_terminal_width(parser2, 80); parser2.add_option(option_value_int, 'i', "int-option", "desc", - seqan3::option_spec::standard, seqan3::value_list_validator{0, -21, 10}); + sharg::option_spec::standard, sharg::value_list_validator{0, -21, 10}); testing::internal::CaptureStderr(); EXPECT_NO_THROW(parser2.parse()); @@ -943,9 +943,9 @@ TEST(validator_test, value_list_validator_success) // positional option const char * argv3[] = {"./argument_parser_test", "ma"}; - seqan3::argument_parser parser3{"test_parser", 2, argv3, seqan3::update_notifications::off}; + sharg::argument_parser parser3{"test_parser", 2, argv3, sharg::update_notifications::off}; test_accessor::set_terminal_width(parser3, 80); - parser3.add_positional_option(option_value, "desc", seqan3::value_list_validator{valid_str_values}); + parser3.add_positional_option(option_value, "desc", sharg::value_list_validator{valid_str_values}); testing::internal::CaptureStderr(); EXPECT_NO_THROW(parser3.parse()); @@ -954,9 +954,9 @@ TEST(validator_test, value_list_validator_success) // positional option - vector const char * argv4[] = {"./argument_parser_test", "ha", "ma"}; - seqan3::argument_parser parser4{"test_parser", 3, argv4, seqan3::update_notifications::off}; + sharg::argument_parser parser4{"test_parser", 3, argv4, sharg::update_notifications::off}; test_accessor::set_terminal_width(parser4, 80); - parser4.add_positional_option(option_vector, "desc", seqan3::value_list_validator{"ha", "ba", "ma"}); + parser4.add_positional_option(option_vector, "desc", sharg::value_list_validator{"ha", "ba", "ma"}); testing::internal::CaptureStderr(); EXPECT_NO_THROW(parser4.parse()); @@ -966,10 +966,10 @@ TEST(validator_test, value_list_validator_success) // option - vector const char * argv5[] = {"./argument_parser_test", "-i", "-10", "-i", "48"}; - seqan3::argument_parser parser5{"test_parser", 5, argv5, seqan3::update_notifications::off}; + sharg::argument_parser parser5{"test_parser", 5, argv5, sharg::update_notifications::off}; test_accessor::set_terminal_width(parser5, 80); parser5.add_option(option_vector_int, 'i', "int-option", "desc", - seqan3::option_spec::standard, seqan3::value_list_validator{-10, 48, 50}); + sharg::option_spec::standard, sharg::value_list_validator{-10, 48, 50}); testing::internal::CaptureStderr(); EXPECT_NO_THROW(parser5.parse()); @@ -980,10 +980,10 @@ TEST(validator_test, value_list_validator_success) // get help page message option_vector_int.clear(); const char * argv7[] = {"./argument_parser_test", "-h"}; - seqan3::argument_parser parser7{"test_parser", 2, argv7, seqan3::update_notifications::off}; + sharg::argument_parser parser7{"test_parser", 2, argv7, sharg::update_notifications::off}; test_accessor::set_terminal_width(parser7, 80); parser7.add_option(option_vector_int, 'i', "int-option", "desc", - seqan3::option_spec::standard, seqan3::value_list_validator{-10, 48, 50}); + sharg::option_spec::standard, sharg::value_list_validator{-10, 48, 50}); option_vector_int.clear(); testing::internal::CaptureStdout(); @@ -1008,53 +1008,53 @@ TEST(validator_test, value_list_validator_error) // option const char * argv[] = {"./argument_parser_test", "-s", "sa"}; - seqan3::argument_parser parser{"test_parser", 3, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 3, argv, sharg::update_notifications::off}; test_accessor::set_terminal_width(parser, 80); parser.add_option(option_value, 's', "string-option", "desc", - seqan3::option_spec::standard, seqan3::value_list_validator{"ha", "ba", "ma"}); + sharg::option_spec::standard, sharg::value_list_validator{"ha", "ba", "ma"}); - EXPECT_THROW(parser.parse(), seqan3::validation_error); + EXPECT_THROW(parser.parse(), sharg::validation_error); // positional option const char * argv3[] = {"./argument_parser_test", "30"}; - seqan3::argument_parser parser3{"test_parser", 2, argv3, seqan3::update_notifications::off}; + sharg::argument_parser parser3{"test_parser", 2, argv3, sharg::update_notifications::off}; test_accessor::set_terminal_width(parser3, 80); - parser3.add_positional_option(option_value_int, "desc", seqan3::value_list_validator{0, 5, 10}); + parser3.add_positional_option(option_value_int, "desc", sharg::value_list_validator{0, 5, 10}); - EXPECT_THROW(parser3.parse(), seqan3::validation_error); + EXPECT_THROW(parser3.parse(), sharg::validation_error); // positional option - vector const char * argv4[] = {"./argument_parser_test", "fo", "ma"}; - seqan3::argument_parser parser4{"test_parser", 3, argv4, seqan3::update_notifications::off}; + sharg::argument_parser parser4{"test_parser", 3, argv4, sharg::update_notifications::off}; test_accessor::set_terminal_width(parser4, 80); parser4.add_positional_option(option_vector, "desc", - seqan3::value_list_validator{"ha", "ba", "ma"}); + sharg::value_list_validator{"ha", "ba", "ma"}); - EXPECT_THROW(parser4.parse(), seqan3::validation_error); + EXPECT_THROW(parser4.parse(), sharg::validation_error); // option - vector const char * argv5[] = {"./argument_parser_test", "-i", "-10", "-i", "488"}; - seqan3::argument_parser parser5{"test_parser", 5, argv5, seqan3::update_notifications::off}; + sharg::argument_parser parser5{"test_parser", 5, argv5, sharg::update_notifications::off}; test_accessor::set_terminal_width(parser5, 80); parser5.add_option(option_vector_int, 'i', "int-option", "desc", - seqan3::option_spec::standard, seqan3::value_list_validator{-10, 48, 50}); + sharg::option_spec::standard, sharg::value_list_validator{-10, 48, 50}); - EXPECT_THROW(parser5.parse(), seqan3::validation_error); + EXPECT_THROW(parser5.parse(), sharg::validation_error); } TEST(validator_test, regex_validator_success) { std::string option_value; std::vector option_vector; - seqan3::regex_validator email_validator("[a-zA-Z]+@[a-zA-Z]+\\.com"); - seqan3::regex_validator email_vector_validator("[a-zA-Z]+@[a-zA-Z]+\\.com"); + sharg::regex_validator email_validator("[a-zA-Z]+@[a-zA-Z]+\\.com"); + sharg::regex_validator email_vector_validator("[a-zA-Z]+@[a-zA-Z]+\\.com"); { // option const char * argv[] = {"./argument_parser_test", "-s", "ballo@rollo.com"}; - seqan3::argument_parser parser{"test_parser", 3, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 3, argv, sharg::update_notifications::off}; test_accessor::set_terminal_width(parser, 80); parser.add_option(option_value, 's', "string-option", "desc", - seqan3::option_spec::standard, email_validator); + sharg::option_spec::standard, email_validator); testing::internal::CaptureStderr(); EXPECT_NO_THROW(parser.parse()); @@ -1064,10 +1064,10 @@ TEST(validator_test, regex_validator_success) { // positional option const char * argv[] = {"./argument_parser_test", "chr1"}; - seqan3::argument_parser parser{"test_parser", 2, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 2, argv, sharg::update_notifications::off}; test_accessor::set_terminal_width(parser, 80); parser.add_positional_option(option_value, "desc", - seqan3::regex_validator{"^chr[0-9]+"}); + sharg::regex_validator{"^chr[0-9]+"}); testing::internal::CaptureStderr(); EXPECT_NO_THROW(parser.parse()); @@ -1077,10 +1077,10 @@ TEST(validator_test, regex_validator_success) { // positional option - vector const char * argv[] = {"./argument_parser_test", "rollo", "bollo", "lollo"}; - seqan3::argument_parser parser{"test_parser", 4, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 4, argv, sharg::update_notifications::off}; test_accessor::set_terminal_width(parser, 80); parser.add_positional_option(option_vector, "desc", - seqan3::regex_validator{".*oll.*"}); + sharg::regex_validator{".*oll.*"}); testing::internal::CaptureStderr(); EXPECT_NO_THROW(parser.parse()); @@ -1093,10 +1093,10 @@ TEST(validator_test, regex_validator_success) { // option - vector option_vector.clear(); const char * argv[] = {"./argument_parser_test", "-s", "rita@rambo.com", "-s", "tina@rambo.com"}; - seqan3::argument_parser parser{"test_parser", 5, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 5, argv, sharg::update_notifications::off}; test_accessor::set_terminal_width(parser, 80); parser.add_option(option_vector, 's', "string-option", "desc", - seqan3::option_spec::standard, email_vector_validator); + sharg::option_spec::standard, email_vector_validator); testing::internal::CaptureStderr(); EXPECT_NO_THROW(parser.parse()); @@ -1108,10 +1108,10 @@ TEST(validator_test, regex_validator_success) { // option - std::filesystem::path std::filesystem::path path_option; const char * argv[] = {"./argument_parser_test", "-s", "rita@rambo.com"}; - seqan3::argument_parser parser{"test_parser", 3, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 3, argv, sharg::update_notifications::off}; test_accessor::set_terminal_width(parser, 80); parser.add_option(path_option, 's', "string-option", "desc", - seqan3::option_spec::standard, email_vector_validator); + sharg::option_spec::standard, email_vector_validator); testing::internal::CaptureStderr(); EXPECT_NO_THROW(parser.parse()); @@ -1122,10 +1122,10 @@ TEST(validator_test, regex_validator_success) { // get help page message option_vector.clear(); const char * argv[] = {"./argument_parser_test", "-h"}; - seqan3::argument_parser parser{"test_parser", 2, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 2, argv, sharg::update_notifications::off}; test_accessor::set_terminal_width(parser, 80); parser.add_option(option_vector, 's', "string-option", "desc", - seqan3::option_spec::standard, email_vector_validator); + sharg::option_spec::standard, email_vector_validator); option_vector.clear(); testing::internal::CaptureStdout(); @@ -1151,40 +1151,40 @@ TEST(validator_test, regex_validator_error) // option const char * argv[] = {"./argument_parser_test", "--string-option", "sally"}; - seqan3::argument_parser parser{"test_parser", 3, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 3, argv, sharg::update_notifications::off}; test_accessor::set_terminal_width(parser, 80); parser.add_option(option_value, '\0', "string-option", "desc", - seqan3::option_spec::standard, seqan3::regex_validator{"tt"}); + sharg::option_spec::standard, sharg::regex_validator{"tt"}); - EXPECT_THROW(parser.parse(), seqan3::validation_error); + EXPECT_THROW(parser.parse(), sharg::validation_error); // positional option const char * argv2[] = {"./argument_parser_test", "jessy"}; - seqan3::argument_parser parser2{"test_parser", 2, argv2, seqan3::update_notifications::off}; + sharg::argument_parser parser2{"test_parser", 2, argv2, sharg::update_notifications::off}; test_accessor::set_terminal_width(parser2, 80); parser2.add_positional_option(option_value, "desc", - seqan3::regex_validator{"[0-9]"}); + sharg::regex_validator{"[0-9]"}); - EXPECT_THROW(parser2.parse(), seqan3::validation_error); + EXPECT_THROW(parser2.parse(), sharg::validation_error); // positional option - vector const char * argv3[] = {"./argument_parser_test", "rollo", "bttllo", "lollo"}; - seqan3::argument_parser parser3{"test_parser", 4, argv3, seqan3::update_notifications::off}; + sharg::argument_parser parser3{"test_parser", 4, argv3, sharg::update_notifications::off}; test_accessor::set_terminal_width(parser3, 80); parser3.add_positional_option(option_vector, "desc", - seqan3::regex_validator{".*oll.*"}); + sharg::regex_validator{".*oll.*"}); - EXPECT_THROW(parser3.parse(), seqan3::validation_error); + EXPECT_THROW(parser3.parse(), sharg::validation_error); // option - vector option_vector.clear(); const char * argv4[] = {"./argument_parser_test", "-s", "gh", "-s", "tt"}; - seqan3::argument_parser parser4{"test_parser", 5, argv4, seqan3::update_notifications::off}; + sharg::argument_parser parser4{"test_parser", 5, argv4, sharg::update_notifications::off}; test_accessor::set_terminal_width(parser4, 80); parser4.add_option(option_vector, 's', "", "desc", - seqan3::option_spec::standard, seqan3::regex_validator{"tt"}); + sharg::option_spec::standard, sharg::regex_validator{"tt"}); - EXPECT_THROW(parser4.parse(), seqan3::validation_error); + EXPECT_THROW(parser4.parse(), sharg::validation_error); } TEST(validator_test, chaining_validators_common_type) @@ -1198,13 +1198,13 @@ TEST(validator_test, chaining_validators_common_type) EXPECT_TRUE((std::same_as, decltype(v_int)>)); EXPECT_TRUE((std::same_as, decltype(v_unsigned)>)); - seqan3::value_list_validator validator_int{v_int}; - seqan3::value_list_validator validator_unsigned{v_unsigned}; + sharg::value_list_validator validator_int{v_int}; + sharg::value_list_validator validator_unsigned{v_unsigned}; - EXPECT_TRUE((std::same_as, decltype(validator_int)>)); + EXPECT_TRUE((std::same_as, decltype(validator_int)>)); EXPECT_TRUE((std::same_as)); - EXPECT_TRUE((std::same_as, decltype(validator_unsigned)>)); + EXPECT_TRUE((std::same_as, decltype(validator_unsigned)>)); EXPECT_TRUE((std::same_as)); auto validator = validator_int | validator_unsigned; @@ -1228,17 +1228,17 @@ TEST(validator_test, chaining_validators_common_type) std::vector v_uint64{4u, static_cast(max_int64)}; std::vector v_double{4.0, static_cast(max_int64)}; - seqan3::value_list_validator validator_int64{v_int64}; - seqan3::value_list_validator validator_uint64{v_uint64}; - seqan3::value_list_validator validator_double{v_double}; + sharg::value_list_validator validator_int64{v_int64}; + sharg::value_list_validator validator_uint64{v_uint64}; + sharg::value_list_validator validator_double{v_double}; - EXPECT_TRUE((std::same_as, decltype(validator_int64)>)); + EXPECT_TRUE((std::same_as, decltype(validator_int64)>)); EXPECT_TRUE((std::same_as)); - EXPECT_TRUE((std::same_as, decltype(validator_uint64)>)); + EXPECT_TRUE((std::same_as, decltype(validator_uint64)>)); EXPECT_TRUE((std::same_as)); - EXPECT_TRUE((std::same_as, decltype(validator_double)>)); + EXPECT_TRUE((std::same_as, decltype(validator_double)>)); EXPECT_TRUE((std::same_as)); auto validator = validator_int64 | validator_uint64 | validator_double; @@ -1258,10 +1258,10 @@ TEST(validator_test, chaining_validators_common_type) // integers have exact match // note: double accepts that value, even though it is not within that list. - EXPECT_THROW(validator_int64(max_int64 - 1), seqan3::validation_error); - EXPECT_THROW(validator_uint64(max_int64 - 1), seqan3::validation_error); + EXPECT_THROW(validator_int64(max_int64 - 1), sharg::validation_error); + EXPECT_THROW(validator_uint64(max_int64 - 1), sharg::validation_error); EXPECT_NO_THROW(validator_double(max_int64 - 1)); - EXPECT_THROW(validator(max_int64 - 1), seqan3::validation_error); + EXPECT_THROW(validator(max_int64 - 1), sharg::validation_error); } } @@ -1269,8 +1269,8 @@ TEST(validator_test, chaining_validators) { std::string option_value{}; std::vector option_vector{}; - seqan3::regex_validator absolute_path_validator{"(/[^/]+)+/.*\\.[^/\\.]+$"}; - seqan3::output_file_validator my_file_ext_validator{seqan3::output_file_open_options::create_new, {"sa", "so"}}; + sharg::regex_validator absolute_path_validator{"(/[^/]+)+/.*\\.[^/\\.]+$"}; + sharg::output_file_validator my_file_ext_validator{sharg::output_file_open_options::create_new, {"sa", "so"}}; seqan3::test::tmp_filename tmp_name{"file.sa"}; std::filesystem::path invalid_extension{tmp_name.get_path()}; @@ -1280,10 +1280,10 @@ TEST(validator_test, chaining_validators) { std::string const & path = tmp_name.get_path().string(); const char * argv[] = {"./argument_parser_test", "-s", path.c_str()}; - seqan3::argument_parser parser{"test_parser", 3, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 3, argv, sharg::update_notifications::off}; test_accessor::set_terminal_width(parser, 80); parser.add_option(option_value, 's', "string-option", "desc", - seqan3::option_spec::standard, absolute_path_validator | my_file_ext_validator); + sharg::option_spec::standard, absolute_path_validator | my_file_ext_validator); testing::internal::CaptureStderr(); EXPECT_NO_THROW(parser.parse()); @@ -1294,35 +1294,35 @@ TEST(validator_test, chaining_validators) { auto rel_path = tmp_name.get_path().relative_path().string(); const char * argv[] = {"./argument_parser_test", "-s", rel_path.c_str()}; - seqan3::argument_parser parser{"test_parser", 3, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 3, argv, sharg::update_notifications::off}; test_accessor::set_terminal_width(parser, 80); parser.add_option(option_value, 's', "string-option", "desc", - seqan3::option_spec::standard, absolute_path_validator | my_file_ext_validator); + sharg::option_spec::standard, absolute_path_validator | my_file_ext_validator); - EXPECT_THROW(parser.parse(), seqan3::validation_error); + EXPECT_THROW(parser.parse(), sharg::validation_error); } { std::string const & path = invalid_extension.string(); const char * argv[] = {"./argument_parser_test", "-s", path.c_str()}; - seqan3::argument_parser parser{"test_parser", 3, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 3, argv, sharg::update_notifications::off}; test_accessor::set_terminal_width(parser, 80); parser.add_option(option_value, 's', "string-option", "desc", - seqan3::option_spec::standard, absolute_path_validator | my_file_ext_validator); + sharg::option_spec::standard, absolute_path_validator | my_file_ext_validator); - EXPECT_THROW(parser.parse(), seqan3::validation_error); + EXPECT_THROW(parser.parse(), sharg::validation_error); } // with temporary validators { std::string const & path = tmp_name.get_path().string(); const char * argv[] = {"./argument_parser_test", "-s", path.c_str()}; - seqan3::argument_parser parser{"test_parser", 3, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 3, argv, sharg::update_notifications::off}; test_accessor::set_terminal_width(parser, 80); parser.add_option(option_value, 's', "string-option", "desc", - seqan3::option_spec::standard, - seqan3::regex_validator{"(/[^/]+)+/.*\\.[^/\\.]+$"} | - seqan3::output_file_validator{seqan3::output_file_open_options::create_new, {"sa", "so"}}); + sharg::option_spec::standard, + sharg::regex_validator{"(/[^/]+)+/.*\\.[^/\\.]+$"} | + sharg::output_file_validator{sharg::output_file_open_options::create_new, {"sa", "so"}}); testing::internal::CaptureStderr(); EXPECT_NO_THROW(parser.parse()); @@ -1334,13 +1334,13 @@ TEST(validator_test, chaining_validators) { std::string const & path = tmp_name.get_path().string(); const char * argv[] = {"./argument_parser_test", "-s", path.c_str()}; - seqan3::argument_parser parser{"test_parser", 3, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 3, argv, sharg::update_notifications::off}; test_accessor::set_terminal_width(parser, 80); parser.add_option(option_value, 's', "string-option", "desc", - seqan3::option_spec::standard, - seqan3::regex_validator{"(/[^/]+)+/.*\\.[^/\\.]+$"} | - seqan3::output_file_validator{seqan3::output_file_open_options::create_new, {"sa", "so"}} | - seqan3::regex_validator{".*"}); + sharg::option_spec::standard, + sharg::regex_validator{"(/[^/]+)+/.*\\.[^/\\.]+$"} | + sharg::output_file_validator{sharg::output_file_open_options::create_new, {"sa", "so"}} | + sharg::regex_validator{".*"}); testing::internal::CaptureStderr(); EXPECT_NO_THROW(parser.parse()); @@ -1352,13 +1352,13 @@ TEST(validator_test, chaining_validators) { option_value.clear(); const char * argv[] = {"./argument_parser_test", "-h"}; - seqan3::argument_parser parser{"test_parser", 2, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 2, argv, sharg::update_notifications::off}; test_accessor::set_terminal_width(parser, 80); parser.add_option(option_value, 's', "string-option", "desc", - seqan3::option_spec::standard, - seqan3::regex_validator{"(/[^/]+)+/.*\\.[^/\\.]+$"} | - seqan3::output_file_validator{seqan3::output_file_open_options::create_new, {"sa", "so"}} | - seqan3::regex_validator{".*"}); + sharg::option_spec::standard, + sharg::regex_validator{"(/[^/]+)+/.*\\.[^/\\.]+$"} | + sharg::output_file_validator{sharg::output_file_open_options::create_new, {"sa", "so"}} | + sharg::regex_validator{".*"}); testing::internal::CaptureStdout(); EXPECT_EXIT(parser.parse(), ::testing::ExitedWithCode(EXIT_SUCCESS), ""); @@ -1381,13 +1381,13 @@ TEST(validator_test, chaining_validators) { option_value.clear(); const char * argv[] = {"./argument_parser_test", "-h"}; - seqan3::argument_parser parser{"test_parser", 2, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 2, argv, sharg::update_notifications::off}; test_accessor::set_terminal_width(parser, 80); parser.add_option(option_value, 's', "string-option", "desc", - seqan3::option_spec::standard, - seqan3::regex_validator{"(/[^/]+)+/.*\\.[^/\\.]+$"} | - seqan3::output_file_validator{seqan3::output_file_open_options::open_or_create, {"sa", "so"}} | - seqan3::regex_validator{".*"}); + sharg::option_spec::standard, + sharg::regex_validator{"(/[^/]+)+/.*\\.[^/\\.]+$"} | + sharg::output_file_validator{sharg::output_file_open_options::open_or_create, {"sa", "so"}} | + sharg::regex_validator{".*"}); testing::internal::CaptureStdout(); EXPECT_EXIT(parser.parse(), ::testing::ExitedWithCode(EXIT_SUCCESS), ""); @@ -1410,12 +1410,12 @@ TEST(validator_test, chaining_validators) std::vector option_list_value{}; std::string const & path = tmp_name.get_path().string(); const char * argv[] = {"./argument_parser_test", "-s", path.c_str()}; - seqan3::argument_parser parser{"test_parser", 3, argv, seqan3::update_notifications::off}; + sharg::argument_parser parser{"test_parser", 3, argv, sharg::update_notifications::off}; test_accessor::set_terminal_width(parser, 80); parser.add_option(option_list_value, 's', "string-option", "desc", - seqan3::option_spec::standard, - seqan3::regex_validator{"(/[^/]+)+/.*\\.[^/\\.]+$"} | - seqan3::output_file_validator{seqan3::output_file_open_options::create_new, {"sa", "so"}}); + sharg::option_spec::standard, + sharg::regex_validator{"(/[^/]+)+/.*\\.[^/\\.]+$"} | + sharg::output_file_validator{sharg::output_file_open_options::create_new, {"sa", "so"}}); testing::internal::CaptureStderr(); EXPECT_NO_THROW(parser.parse());