2023-08-08 12:35:59 +02:00

94 lines
3.1 KiB
C++

//
// main.cpp
// tester
//
// Created by Bob Polis at 2020-04-29
// Copyright (c) 2020 SwiftCoder. All rights reserved.
//
#include <iostream>
#include <cstdlib>
#include <string>
#include <getopt.h>
#include <libsclogging.hpp>
void print_help() {
std::cout << "usage: tester [-h][-v]\n";
std::cout << " -h, --help show this help text and exit\n";
std::cout << " -v, --version show version number and exit\n";
}
void print_version() {
std::cout << "tester version 1.0\n";
}
int main(int argc, const char * argv[]) {
try {
struct option long_options[] = {
{"help", no_argument, nullptr, 'h'},
{"test", required_argument, nullptr, 't'},
{"version", no_argument, nullptr, 'v'},
{nullptr, 0, nullptr, 0}
};
int opt_char, option_index;
while ((opt_char = getopt_long(argc, const_cast<char* const *>(argv), "ht:v", long_options, &option_index)) != -1) {
switch (opt_char) {
case 0: {
// handle long-only options here
std::string optname {long_options[option_index].name};
break;
}
case 'h':
print_help();
return EXIT_SUCCESS;
case 'v':
print_version();
return EXIT_SUCCESS;
case '?':
throw std::runtime_error("unrecognized option");
}
}
if (optind == argc) {
// here when no file args
}
for (int i = optind; i < argc; ++i) {
try {
// process file argv[i]
} catch (const std::runtime_error& ex) {
std::cerr << "tester: " << ex.what() << '\n';
}
}
std::cout << "hello, tester\n";
sc::logger logger("tester", sc::loglevel::debug);
SCDebug(logger, "efkes proberen");
SCInfo(logger, 42, " = ", 6, " x ", 7);
SCWarning(logger, "laatste waarschuwing");
SCError(logger, "foutje, bedankt");
SCCritical(logger, "meltdown imminent");
SCInfo(logger, "");
sclog("%s", "oud spul werkt ook");
SCInfoC(logger, sc::io::black, "black");
SCInfoC(logger, sc::io::red, "red");
SCInfoC(logger, sc::io::green, "green");
SCInfoC(logger, sc::io::yellow, "yellow");
SCInfoC(logger, sc::io::blue, "blue");
SCInfoC(logger, sc::io::magenta, "magenta");
SCInfoC(logger, sc::io::cyan, "cyan");
SCInfoC(logger, sc::io::white, "white");
sc::io::trgb orange {1.0, 0.5, 0.0};
SCInfoC(logger, orange, "orange");
sc::io::trgb c1 {0.0, 0.7, 0.7};
SCInfoC(logger, c1, "c1");
sc::io::trgb c2 {0.7, 0.3, 0.7};
SCInfoC(logger, c2, "c2");
sc::io::trgb c3 {0.4, 0.4, 0.2};
SCInfoC(logger, c3, "c3");
sc::io::trgb c4 {0.2, 0.6, 0.2};
SCInfoC(logger, c4, "c4");
} catch (const std::exception& ex) {
std::cerr << "tester: " << ex.what() << '\n';
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}