Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MISC] header #27

Merged
merged 12 commits into from
Dec 6, 2021
5 changes: 2 additions & 3 deletions doc/cookbook/basic_arg_parse.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#include <sharg/all.hpp>
#include <seqan3/core/debug_stream.hpp>

void run_program(std::filesystem::path const & reference_path,
std::filesystem::path const & index_path)
{
seqan3::debug_stream << "reference_file_path: " << reference_path << '\n';
seqan3::debug_stream << "index_path " << index_path << '\n';
std::cerr << "reference_file_path: " << reference_path << '\n';
std::cerr << "index_path " << index_path << '\n';
}

struct cmd_arguments
Expand Down
14 changes: 8 additions & 6 deletions doc/howto/subcommand_argument_parser/subcommand_arg_parse.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include <sharg/all.hpp>
#include <seqan3/core/debug_stream.hpp>

// =====================================================================================================================
// pull
Expand All @@ -25,11 +24,11 @@ int run_git_pull(sharg::argument_parser & parser)
}
catch (sharg::argument_parser_error const & ext)
{
seqan3::debug_stream << "[Error git pull] " << ext.what() << "\n";
std::cerr << "[Error git pull] " << ext.what() << "\n";
return -1;
}

seqan3::debug_stream << "Git pull with repository " << args.repository << " and branch " << args.branch << '\n';
std::cerr << "Git pull with repository " << args.repository << " and branch " << args.branch << '\n';

return 0;
}
Expand Down Expand Up @@ -58,11 +57,14 @@ int run_git_push(sharg::argument_parser & parser)
}
catch (sharg::argument_parser_error const & ext)
{
seqan3::debug_stream << "[Error git push] " << ext.what() << "\n";
std::cerr << "[Error git push] " << ext.what() << "\n";
return -1;
}

seqan3::debug_stream << "Git push with repository " << args.repository << " and branches " << args.branches << '\n';
std::cerr << "Git push with repository " << args.repository << " and branches ";
for (auto && branch : args.branches)
std::cerr << branch << ' ';
std::cerr << '\n';

return 0;
}
Expand Down Expand Up @@ -93,7 +95,7 @@ int main(int argc, char const ** argv)
}
catch (sharg::argument_parser_error const & ext) // catch user errors
{
seqan3::debug_stream << "[Error] " << ext.what() << "\n"; // customise your error message
std::cerr << "[Error] " << ext.what() << "\n"; // customise your error message
return -1;
}

Expand Down
3 changes: 1 addition & 2 deletions doc/tutorial/argument_parser/basic_parser_setup.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include <sharg/all.hpp> // includes all necessary headers
#include <seqan3/core/debug_stream.hpp> // our custom output stream

int main(int argc, char ** argv)
{
Expand All @@ -13,7 +12,7 @@ int main(int argc, char ** argv)
}
catch (sharg::argument_parser_error const & ext) // catch user errors
{
seqan3::debug_stream << "[Winter has come] " << ext.what() << "\n"; // customise your error message
std::cerr << "[Winter has come] " << ext.what() << "\n"; // customise your error message
return -1;
}
}
1 change: 0 additions & 1 deletion doc/tutorial/argument_parser/small_snippets.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include <sharg/all.hpp>
#include <filesystem>

//![validator_include]
#include <sharg/validators.hpp>
Expand Down
1 change: 0 additions & 1 deletion doc/tutorial/argument_parser/solution1.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include <sharg/all.hpp> // includes all necessary headers
#include <seqan3/core/debug_stream.hpp> // our custom output stream

void initialise_argument_parser(sharg::argument_parser & parser)
{
Expand Down
18 changes: 6 additions & 12 deletions doc/tutorial/argument_parser/solution3.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
//![program]
#include <seqan3/std/charconv> // includes std::from_chars
#include <filesystem> // use std::filesystem::path
#include <fstream>
#include <numeric>

#include <sharg/all.hpp> // includes all necessary headers
#include <seqan3/core/debug_stream.hpp> // our custom output stream

// This is the program!
// Take a look at it if you are interested in an example of parsing a data file.
Expand All @@ -20,7 +14,7 @@ number_type to_number(range_type && range)

if (res.ec != std::errc{})
{
seqan3::debug_stream << "Could not cast '" << range << "' to a valid number\n";
std::cerr << "Could not cast '" << str << "' to a valid number\n";
throw std::invalid_argument{"CAST ERROR"};
}
return num;
Expand Down Expand Up @@ -48,16 +42,16 @@ void run_program(std::filesystem::path & path, uint32_t yr, std::string & aggr_b
}

if (aggr_by == "median")
seqan3::debug_stream << ([&v] () { std::sort(v.begin(), v.end()); return v[v.size()/2]; })() << '\n';
std::cerr << ([&v] () { std::sort(v.begin(), v.end()); return v[v.size()/2]; })() << '\n';
else if (aggr_by == "mean")
seqan3::debug_stream << ([&v] () { double sum{}; for (auto i : v) sum += i; return sum / v.size(); })()
std::cerr << ([&v] () { double sum{}; for (auto i : v) sum += i; return sum / v.size(); })()
<< '\n';
else
seqan3::debug_stream << "I do not know the aggregation method " << aggr_by << '\n';
std::cerr << "I do not know the aggregation method " << aggr_by << '\n';
}
else
{
seqan3::debug_stream << "Error: Cannot open file for reading.\n";
std::cerr << "Error: Cannot open file for reading.\n";
}
}
// -----------------------------------------------------------------------------
Expand Down Expand Up @@ -102,7 +96,7 @@ int main(int argc, char ** argv)
}
catch (sharg::argument_parser_error const & ext) // catch user errors
{
seqan3::debug_stream << "[Winter has come] " << ext.what() << "\n"; // customise your error message
std::cerr << "[Winter has come] " << ext.what() << "\n"; // customise your error message
return -1;
}

Expand Down
18 changes: 6 additions & 12 deletions doc/tutorial/argument_parser/solution4.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
#include <fstream>
#include <numeric>

#include <sharg/all.hpp> // includes all necessary headers
#include <seqan3/core/debug_stream.hpp> // our custom output stream
#include <seqan3/std/charconv> // includes std::from_chars
#include <filesystem> // use std::filesystem::path

// This is the program!
// Take a look at it if you are interested in an example of parsing a data file.
Expand All @@ -19,7 +13,7 @@ number_type to_number(range_type && range)

if (res.ec != std::errc{})
{
seqan3::debug_stream << "Could not cast '" << range << "' to a valid number\n";
std::cerr << "Could not cast '" << str << "' to a valid number\n";
throw std::invalid_argument{"CAST ERROR"};
}
return num;
Expand Down Expand Up @@ -49,16 +43,16 @@ void run_program(std::filesystem::path & path, std::vector<uint8_t> sn, std::str
//![altered_while]

if (aggr_by == "median")
seqan3::debug_stream << ([&v] () { std::sort(v.begin(), v.end()); return v[v.size()/2]; })() << '\n';
std::cerr << ([&v] () { std::sort(v.begin(), v.end()); return v[v.size()/2]; })() << '\n';
else if (aggr_by == "mean")
seqan3::debug_stream << ([&v] () { double sum{}; for (auto i : v) sum += i; return sum / v.size(); })()
std::cerr << ([&v] () { double sum{}; for (auto i : v) sum += i; return sum / v.size(); })()
<< '\n';
else
seqan3::debug_stream << "I do not know the aggregation method " << aggr_by << '\n';
std::cerr << "I do not know the aggregation method " << aggr_by << '\n';
}
else
{
seqan3::debug_stream << "Error: Cannot open file for reading.\n";
std::cerr << "Error: Cannot open file for reading.\n";
}
}
// -----------------------------------------------------------------------------
Expand Down Expand Up @@ -102,7 +96,7 @@ int main(int argc, char ** argv)
}
catch (sharg::argument_parser_error const & ext) // catch user errors
{
seqan3::debug_stream << "[Winter has come] " << ext.what() << "\n"; // customise your error message
std::cerr << "[Winter has come] " << ext.what() << "\n"; // customise your error message
return -1;
}

Expand Down
18 changes: 6 additions & 12 deletions doc/tutorial/argument_parser/solution5.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
#include <fstream>
#include <numeric>

#include <sharg/all.hpp> // includes all necessary headers
#include <seqan3/core/debug_stream.hpp> // our custom output stream
#include <seqan3/std/charconv> // includes std::from_chars
#include <filesystem> // use std::filesystem::path

// This is the program!
// Take a look at it if you are interested in an example of parsing a data file.
Expand All @@ -19,7 +13,7 @@ number_type to_number(range_type && range)

if (res.ec != std::errc{})
{
seqan3::debug_stream << "Could not cast '" << range << "' to a valid number\n";
std::cerr << "Could not cast '" << str << "' to a valid number\n";
throw std::invalid_argument{"CAST ERROR"};
}
return num;
Expand Down Expand Up @@ -47,16 +41,16 @@ void run_program(std::filesystem::path & path, std::vector<uint8_t> sn, std::str
}

if (aggr_by == "median")
seqan3::debug_stream << ([&v] () { std::sort(v.begin(), v.end()); return v[v.size()/2]; })() << '\n';
std::cerr << ([&v] () { std::sort(v.begin(), v.end()); return v[v.size()/2]; })() << '\n';
else if (aggr_by == "mean")
seqan3::debug_stream << ([&v] () { double sum{}; for (auto i : v) sum += i; return sum / v.size(); })()
std::cerr << ([&v] () { double sum{}; for (auto i : v) sum += i; return sum / v.size(); })()
<< '\n';
else
seqan3::debug_stream << "I do not know the aggregation method " << aggr_by << '\n';
std::cerr << "I do not know the aggregation method " << aggr_by << '\n';
}
else
{
seqan3::debug_stream << "Error: Cannot open file for reading.\n";
std::cerr << "Error: Cannot open file for reading.\n";
}
}
// -----------------------------------------------------------------------------
Expand Down Expand Up @@ -100,7 +94,7 @@ int main(int argc, char ** argv)
}
catch (sharg::argument_parser_error const & ext) // catch user errors
{
seqan3::debug_stream << "[Winter has come] " << ext.what() << "\n"; // customise your error message
std::cerr << "[Winter has come] " << ext.what() << "\n"; // customise your error message
return -1;
}

Expand Down
18 changes: 6 additions & 12 deletions doc/tutorial/argument_parser/solution6.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
#include <fstream>
#include <numeric>

#include <sharg/all.hpp> // includes all necessary headers
#include <seqan3/core/debug_stream.hpp> // our custom output stream
#include <seqan3/std/charconv> // includes std::from_chars
#include <filesystem> // use std::filesystem::path

// This is the program!
// Take a look at it if you are interested in an example of parsing a data file.
Expand All @@ -19,7 +13,7 @@ number_type to_number(range_type && range)

if (res.ec != std::errc{})
{
seqan3::debug_stream << "Could not cast '" << range << "' to a valid number\n";
std::cerr << "Could not cast '" << str << "' to a valid number\n";
throw std::invalid_argument{"CAST ERROR"};
}
return num;
Expand Down Expand Up @@ -47,16 +41,16 @@ void run_program(std::filesystem::path & path, std::vector<uint8_t> sn, std::str
}

if (aggr_by == "median")
seqan3::debug_stream << ([&v] () { std::sort(v.begin(), v.end()); return v[v.size()/2]; })() << '\n';
std::cerr << ([&v] () { std::sort(v.begin(), v.end()); return v[v.size()/2]; })() << '\n';
else if (aggr_by == "mean")
seqan3::debug_stream << ([&v] () { double sum{}; for (auto i : v) sum += i; return sum / v.size(); })()
std::cerr << ([&v] () { double sum{}; for (auto i : v) sum += i; return sum / v.size(); })()
<< '\n';
else
seqan3::debug_stream << "I do not know the aggregation method " << aggr_by << '\n';
std::cerr << "I do not know the aggregation method " << aggr_by << '\n';
}
else
{
seqan3::debug_stream << "Error: Cannot open file for reading.\n";
std::cerr << "Error: Cannot open file for reading.\n";
}
}
// -----------------------------------------------------------------------------
Expand Down Expand Up @@ -107,7 +101,7 @@ int main(int argc, char ** argv)
}
catch (sharg::argument_parser_error const & ext) // catch user errors
{
seqan3::debug_stream << "[Winter has come] " << ext.what() << "\n"; // customise your error message
std::cerr << "[Winter has come] " << ext.what() << "\n"; // customise your error message
return -1;
}

Expand Down
12 changes: 2 additions & 10 deletions include/sharg/argument_parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,16 @@

#pragma once

#include <future>
#include <iostream>
#include <set>
#include <sstream>
#include <string>
#include <variant>
#include <vector>
#include <regex>

// #include <sharg/detail/format_ctd.hpp>
#include <seqan3/core/debug_stream/detail/to_string.hpp>

#include <sharg/detail/format_help.hpp>
#include <sharg/detail/format_html.hpp>
#include <sharg/detail/format_man.hpp>
#include <sharg/detail/format_parse.hpp>
#include <sharg/detail/terminal.hpp>
#include <sharg/detail/version_check.hpp>
#include <seqan3/core/debug_stream/detail/to_string.hpp>
#include <seqan3/core/detail/test_accessor.hpp>

namespace sharg
{
Expand Down
5 changes: 2 additions & 3 deletions include/sharg/auxiliary.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,15 @@

#pragma once

#include <seqan3/std/concepts>
#include <sstream>
#include <seqan3/std/type_traits>
#include <unordered_map>
#include <vector>

#include <seqan3/core/debug_stream/debug_stream_type.hpp>
#include <seqan3/core/detail/customisation_point.hpp>
#include <seqan3/io/stream/concept.hpp>

#include <sharg/platform.hpp>

namespace sharg::custom
{

Expand Down
2 changes: 0 additions & 2 deletions include/sharg/detail/concept.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@

#pragma once

#include <seqan3/std/concepts>
#include <string>
#include <seqan3/std/type_traits>

#include <sharg/platform.hpp>

Expand Down
10 changes: 3 additions & 7 deletions include/sharg/detail/format_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,14 @@

#pragma once

#include <filesystem>
#include <iostream>
#include <limits>
#include <sstream>
#include <string>
#include <seqan3/utility/detail/type_name_as_string.hpp>
#include <seqan3/utility/type_list/traits.hpp>

#include <sharg/auxiliary.hpp>
#include <sharg/detail/concept.hpp>
#include <sharg/exceptions.hpp>
#include <sharg/validators.hpp>
#include <seqan3/utility/detail/type_name_as_string.hpp>
#include <seqan3/version.hpp>
#include <sharg/version.hpp>

namespace sharg::detail
{
Expand Down
11 changes: 7 additions & 4 deletions include/sharg/detail/format_help.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@

#pragma once

#include <cassert>
#include <iostream>

#include <sharg/detail/format_base.hpp>
#include <sharg/detail/terminal.hpp>
#include <seqan3/core/detail/test_accessor.hpp>

namespace seqan3::detail
{

struct test_accessor;

} // seqan3::detail
Comment on lines +19 to +25
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I adapted #14 to remove this declaration and replace it with the sharg include


namespace sharg::detail
{
Expand Down
4 changes: 1 addition & 3 deletions include/sharg/detail/format_html.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@

#pragma once

#include <iostream>

#include <sharg/detail/format_base.hpp>
#include <sharg/detail/terminal.hpp>
#include <seqan3/version.hpp>
#include <sharg/version.hpp>

namespace sharg::detail
{
Expand Down
Loading