diff --git a/CHANGELOG.md b/CHANGELOG.md index bac14dfd..01231450 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,7 +28,9 @@ If possible, provide tooling that performs the changes, e.g. a shell-script. #### I/O -* To avoid using seqan3::io we changed the usage of the `seqan3::input_file_validator` and -`seqan3::output_file_validator`, you now have to give the formats explicitly: -`sharg::input_file_validator validator{std::vector{std::string{"exe"}, std::string{"fasta"}}};` and -`sharg::output_file_validator validator{sharg::output_file_open_options::create_new, std::vector{std::string{"exe"}, std::string{"fasta"}}};`. +* In order to avoid using the seqan3 I/O module, you now have to give a list of file extensions explicitly to +`sharg::input_file_validator` and `sharg::output_file_validator`: +For example `sharg::input_file_validator validator{std::vector{{"exe"}, {"fasta"}}};`. Please follow +https://github.com/seqan/seqan3/issues/2927 to see how the list of file extensions can be extracted from seqan3 files. +We also removed the `default_extensions()` function, as we now can construct `output_file_validator` with just a given +mode: `output_file_validator(output_file_open_options const mode)`. The extensions will be an empty array in this case. diff --git a/include/sharg/validators.hpp b/include/sharg/validators.hpp index 8422363e..13578dfa 100644 --- a/include/sharg/validators.hpp +++ b/include/sharg/validators.hpp @@ -467,9 +467,7 @@ class file_validator_base * * \include test/snippet/argument_parser/validators_input_file.cpp * - * 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 sharg::input_file_validator. + * The following snippet demonstrates the different ways to instantiate the sharg::input_file_validator. * * \include test/snippet/argument_parser/validators_input_file_ext_from_file.cpp * @@ -488,6 +486,7 @@ class input_file_validator : public file_validator_base * \{ */ + input_file_validator() = default; //!< Defaulted. input_file_validator(input_file_validator const &) = default; //!< Defaulted. input_file_validator(input_file_validator &&) = default; //!< Defaulted. input_file_validator & operator=(input_file_validator const &) = default; //!< Defaulted. @@ -575,9 +574,7 @@ enum class output_file_open_options * * \include test/snippet/argument_parser/validators_output_file.cpp * - * 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 sharg::output_file_validator. + * The following snippet demonstrates the different ways to instantiate the sharg::output_file_validator. * * \include test/snippet/argument_parser/validators_output_file_ext_from_file.cpp * @@ -597,23 +594,31 @@ class output_file_validator : public file_validator_base */ //!\copydoc sharg::input_file_validator::input_file_validator() - output_file_validator() : output_file_validator{output_file_open_options::create_new} - {} + output_file_validator() : output_file_validator{output_file_open_options::create_new} {} - output_file_validator(output_file_validator const &) = default; //!< Defaulted. - output_file_validator(output_file_validator &&) = default; //!< Defaulted. + output_file_validator(output_file_validator const &) = default; //!< Defaulted. + output_file_validator(output_file_validator &&) = default; //!< Defaulted. output_file_validator & operator=(output_file_validator const &) = default; //!< Defaulted. - output_file_validator & operator=(output_file_validator &&) = default; //!< Defaulted. + output_file_validator & operator=(output_file_validator &&) = default; //!< Defaulted. virtual ~output_file_validator() = default; //!< Virtual Destructor. + /*!\brief Constructs from a given overwrite mode. + * \param[in] mode A sharg::output_file_open_options indicating whether the validator throws if a file already + exists. + */ + explicit output_file_validator(output_file_open_options const mode) + : file_validator_base{}, mode{mode} + { + file_validator_base::extensions = std::move(std::vector {}); + file_validator_base::extensions_str = std::string {}; + } + /*!\brief Constructs from a given overwrite mode and a list of valid extensions. * \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 - * sharg::output_file_validator::default_extensions. + * \param[in] extensions The valid extensions to validate for. */ - explicit output_file_validator(output_file_open_options const mode, - std::vector extensions = default_extensions()) + explicit output_file_validator(output_file_open_options const mode, std::vector extensions) : file_validator_base{}, mode{mode} { file_validator_base::extensions = std::move(extensions); @@ -624,14 +629,6 @@ class output_file_validator : public file_validator_base using file_validator_base::file_validator_base; //!\} - /*!\brief The default extensions of `file_t`. - * \returns A list of default extensions for `file_t`, will be empty if `file_t` is `void`. - */ - static std::vector default_extensions() - { - return {}; - } - // Import the base::operator() using file_validator_base::operator();