Skip to content

Commit

Permalink
[INFRA] Change namespace to sharg
Browse files Browse the repository at this point in the history
  • Loading branch information
eseiler committed Dec 1, 2021
1 parent aeca5ef commit 0c67b05
Show file tree
Hide file tree
Showing 46 changed files with 993 additions and 1,042 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_misc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ concurrency:
cancel-in-progress: true

env:
SEQAN3_NO_VERSION_CHECK: 1
SHARG_NO_VERSION_CHECK: 1
TZ: Europe/Berlin

defaults:
Expand Down
2 changes: 1 addition & 1 deletion build_system/sharg-config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 11 additions & 11 deletions include/sharg/all.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
154 changes: 77 additions & 77 deletions include/sharg/argument_parser.hpp

Large diffs are not rendered by default.

106 changes: 46 additions & 60 deletions include/sharg/auxiliary.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -22,10 +22,10 @@
#include <seqan3/core/detail/customisation_point.hpp>
#include <seqan3/io/stream/concept.hpp>

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
Expand All @@ -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
*
Expand Down Expand Up @@ -65,23 +65,23 @@ struct argument_parsing<t const &> : argument_parsing<t>
{};
//!\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 <typename t>
std::unordered_map<std::string_view, t> 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 <typename option_t>
struct enumeration_names_cpo : public detail::customisation_point_object<enumeration_names_cpo<option_t>, 1>
struct enumeration_names_cpo : public seqan3::detail::customisation_point_object<enumeration_names_cpo<option_t>, 1>
{
//!\brief CRTP base class seqan3::detail::customisation_point_object.
using base_t = detail::customisation_point_object<enumeration_names_cpo<option_t>, 1>;
using base_t = seqan3::detail::customisation_point_object<enumeration_names_cpo<option_t>, 1>;
//!\brief Only this class is allowed to import the constructors from #base_t. (CRTP safety idiom)
using base_t::base_t;

Expand All @@ -94,13 +94,13 @@ struct enumeration_names_cpo : public detail::customisation_point_object<enumera
std::remove_cvref_t<option_type>,
std::type_identity<option_type>>;

/*!\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 <typename option_type = option_t>
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<option_type>::enumeration_names /*;*/
/*return*/ sharg::custom::argument_parsing<option_type>::enumeration_names /*;*/
);

/*!\brief CPO overload (check 1 out of 2): argument dependent lookup (ADL), i.e.
Expand All @@ -113,15 +113,15 @@ struct enumeration_names_cpo : public detail::customisation_point_object<enumera
* `enumeration_names(std::type_identity<option_t>{})` will be called.
*/
template <typename option_type = option_t>
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<option_type>{}) /*;*/
);
};

} // namespace seqan3::detail::adl_only
} // namespace sharg::detail::adl_only

namespace seqan3
namespace sharg
{

/*!\name Customisation Points
Expand All @@ -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<your_type>` that is of type
* 1. A static member `enumeration_names` in `sharg::custom::argument_parsing<your_type>` that is of type
* `std::unordered_map<std::string_view, your_type>>`.
* 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<std::string_view, your_type>>`.
Expand All @@ -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
*
Expand All @@ -169,73 +169,41 @@ template <typename option_type>
inline auto const enumeration_names = detail::adl_only::enumeration_names_cpo<option_type>{}();
//!\}

/*!\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<option_type> must exist and be of type
* * A instance of sharg::enumeration_names<option_type> must exist and be of type
* `std::unordered_map<std::string, option_type>`.
*
* \remark For a complete overview, take a look at \ref argument_parser
*/
//!\cond
template <typename option_type>
concept named_enumeration = requires
{
{ seqan3::enumeration_names<option_type> };
{ sharg::enumeration_names<option_type> };
};
//!\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.
*
* ### Requirements
*
* In order to model this concept, the type must either be streamable to std::istringstream or
* model seqan3::named_enumeration<option_type>.
* model sharg::named_enumeration<option_type>.
*
* \remark For a complete overview, take a look at \ref argument_parser
*/
//!\cond
template <typename option_type>
concept argument_parser_compatible_option = input_stream_over<std::istringstream, option_type> ||
concept argument_parser_compatible_option = seqan3::input_stream_over<std::istringstream, option_type> ||
named_enumeration<option_type>;
//!\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 '\<UNKNOWN_VALUE\>' if the value cannot be found in the map.
*/
template <typename char_t, typename option_type>
//!\cond
requires named_enumeration<std::remove_cvref_t<option_type>>
//!\endcond
inline debug_stream_type<char_t> & operator<<(debug_stream_type<char_t> & s, option_type && op)
{
for (auto & [key, value] : enumeration_names<option_type>)
{
if (op == value)
return s << key;
}

return s << "<UNKNOWN_VALUE>";
}
//!\}

/*!\brief Used to further specify argument_parser options/flags.
* \ingroup argument_parser
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -340,4 +308,22 @@ struct argument_parser_meta_data // holds all meta information
std::vector<std::string> examples;
};

} // namespace seqan3
} // namespace sharg

//!\cond
namespace seqan3
{
template <typename char_t, typename option_type>
requires sharg::named_enumeration<std::remove_cvref_t<option_type>>
inline debug_stream_type<char_t> & operator<<(debug_stream_type<char_t> & s, option_type && op)
{
for (auto & [key, value] : sharg::enumeration_names<option_type>)
{
if (op == value)
return s << key;
}

return s << "<UNKNOWN_VALUE>";
}
}
//!\endcond
12 changes: 5 additions & 7 deletions include/sharg/detail/concept.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <svenja.mehringer AT fu-berlin.de>
* \brief Provides the concept seqan3::detail::is_container_option.
* \brief Provides the concept sharg::detail::is_container_option.
*/

#pragma once
Expand All @@ -18,10 +18,10 @@

#include <seqan3/core/platform.hpp>

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
Expand All @@ -38,14 +38,12 @@ namespace seqan3::detail
*
* \noapi
*/
//!\cond
template <typename option_type>
concept is_container_option = !std::is_same_v<std::remove_cvref_t<option_type>, std::string> &&
requires (option_type container,
typename std::remove_reference_t<option_type>::value_type value)
{
{ container.push_back(value) };
};
//!\endcond

} // namespace seqan3::detail
} // namespace sharg::detail
Loading

0 comments on commit 0c67b05

Please sign in to comment.