You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.9 KiB
54 lines
1.9 KiB
#include <iostream>
|
|
|
|
#include "popl.hpp"
|
|
#include "OptionParser.h"
|
|
|
|
namespace parser {
|
|
int printPoplException(const popl::invalid_option &e) {
|
|
std::cerr << "Invalid Option Exception: " << e.what() << "\n";
|
|
std::cerr << "error: ";
|
|
if (e.error() == popl::invalid_option::Error::missing_argument) {
|
|
std::cerr << "missing_argument\n";
|
|
} else if (e.error() == popl::invalid_option::Error::invalid_argument) {
|
|
std::cerr << "invalid_argument\n";
|
|
} else if (e.error() == popl::invalid_option::Error::too_many_arguments) {
|
|
std::cerr << "too_many_arguments\n";
|
|
} else if (e.error() == popl::invalid_option::Error::missing_option) {
|
|
std::cerr << "missing_option\n";
|
|
}
|
|
|
|
if (e.error() == popl::invalid_option::Error::missing_option) {
|
|
std::string option_name(e.option()->name(popl::OptionName::short_name, true));
|
|
if (option_name.empty())
|
|
option_name = e.option()->name(popl::OptionName::long_name, true);
|
|
std::cerr << "option: " << option_name << "\n";
|
|
}
|
|
else {
|
|
std::cerr << "option: " << e.option()->name(e.what_name()) << "\n";
|
|
std::cerr << "value: " << e.value() << "\n";
|
|
}
|
|
return EXIT_FAILURE;
|
|
}
|
|
|
|
|
|
int checkOption(const int input_filename_count,
|
|
const int input_string_count) {
|
|
if(input_filename_count > 1) {
|
|
std::cerr << "You may only pass one input graph file.\n";
|
|
return INPUT_ERROR;
|
|
}
|
|
if(input_string_count > 1) {
|
|
std::cerr << "You may only pass one input graph string.\n";
|
|
return INPUT_ERROR;
|
|
}
|
|
if(input_filename_count > 0 && input_string_count > 0) {
|
|
std::cerr << "You may only pass either an input graph file or an input graph string.\n";
|
|
return INPUT_ERROR;
|
|
}
|
|
if(input_filename_count == 0 && input_string_count == 0) {
|
|
std::cerr << "You need to pass either and input graph file or an input graph string.\n";
|
|
return INPUT_ERROR;
|
|
}
|
|
return INPUT_OK;
|
|
}
|
|
}
|