Restyle to K&R

This commit is contained in:
rr-
2016-02-24 18:10:03 +01:00
parent a84aeaea96
commit 326c164e09
3 changed files with 8 additions and 17 deletions

View File

@ -24,8 +24,7 @@ static void show_usage(const bool include_help)
std::cout << "opustags v" << version << "\n";
std::cout << usage;
if (include_help)
{
if (include_help) {
std::cout << "\n";
std::cout << help;
}
@ -33,25 +32,20 @@ static void show_usage(const bool include_help)
int main(int argc, char **argv)
{
if (argc == 1)
{
if (argc == 1) {
show_usage(false);
return EXIT_SUCCESS;
}
try
{
try {
const auto options = opustags::parse_args(argc, argv);
if (options.show_help)
{
if (options.show_help) {
show_usage(true);
return EXIT_SUCCESS;
}
std::cout << "Working...\n";
}
catch (const std::exception &e)
{
} catch (const std::exception &e) {
std::cerr << e.what();
return EXIT_FAILURE;
}

View File

@ -36,12 +36,10 @@ Options opustags::parse_args(const int argc, char **argv)
Options options;
char c;
optind = 0;
while ((c = getopt_long(argc, argv, short_def, long_def, nullptr)) != -1)
{
while ((c = getopt_long(argc, argv, short_def, long_def, nullptr)) != -1) {
const std::string arg(optarg == nullptr ? "" : optarg);
switch (c)
{
switch (c) {
case 'h':
options.show_help = true;
break;

View File

@ -21,9 +21,8 @@ namespace opustags
std::vector<std::string> to_delete;
};
class ArgumentError : public std::runtime_error
struct ArgumentError : std::runtime_error
{
public:
ArgumentError(const std::string &message);
};