add help and version

This commit is contained in:
PoliEcho 2025-03-26 20:07:50 +01:00
parent 1966eef865
commit b839965183
2 changed files with 69 additions and 3 deletions

23
src/color.h Normal file
View File

@ -0,0 +1,23 @@
// Header guard
#ifndef RESET
#define RESET "\033[0m"
#define BLACK "\033[30m" /* Black */
#define RED "\033[31m" /* Red */
#define GREEN "\033[32m" /* Green */
#define YELLOW "\033[33m" /* Yellow */
#define BLUE "\033[34m" /* Blue */
#define MAGENTA "\033[35m" /* Magenta */
#define CYAN "\033[36m" /* Cyan */
#define WHITE "\033[37m" /* White */
#define BOLDBLACK "\033[1m\033[30m" /* Bold Black */
#define BOLDRED "\033[1m\033[31m" /* Bold Red */
#define BOLDGREEN "\033[1m\033[32m" /* Bold Green */
#define BOLDYELLOW "\033[1m\033[33m" /* Bold Yellow */
#define BOLDBLUE "\033[1m\033[34m" /* Bold Blue */
#define BOLDMAGENTA "\033[1m\033[35m" /* Bold Magenta */
#define BOLDCYAN "\033[1m\033[36m" /* Bold Cyan */
#define BOLDWHITE "\033[1m\033[37m" /* Bold White */
#endif

View File

@ -1,7 +1,50 @@
#include "color.h"
#include <cstdlib>
#include <iostream>
#include <unistd.h>
#define NAME "ParaDocs"
#define VERSION "0.0.1"
void PrintHelp() {
std::cout << RED R"( ____ ____
/\ _`\ /\ _`\
\ \ \L\ \ __ _ __ __ \ \ \/\ \ ___ ___ ____
\ \ ,__/'__`\ /\`'__\/'__`\ \ \ \ \ \ / __`\ /'___\ /',__\
\ \ \/\ \L\.\_\ \ \//\ \L\.\_\ \ \_\ \/\ \L\ \/\ \__//\__, `\
\ \_\ \__/.\_\\ \_\\ \__/.\_\\ \____/\ \____/\ \____\/\____/
\/_/\/__/\/_/ \/_/ \/__/\/_/ \/___/ \/___/ \/____/\/___/)"
<< RESET "\nUsage:\n"
<< NAME << " [options]\n"
<< "-h\t\tPrint this help\n"
<< "-V\t\tPrint version\n";
exit(0);
}
void PrintVersion() {
std::cout << NAME << " version " << VERSION << "\n";
exit(0);
}
int main(int argc, char *argv[]) {
for(int i= 0;i < 10; i++){
std::cout << "trestní oznámení\n";
}
int opt;
while ((opt = getopt(argc, argv, "hV")) != -1) {
switch (opt) {
case 'h':
PrintHelp();
break;
case 'V':
PrintVersion();
break;
default:
std::cerr << RED "[ERROR]" << RESET " invalid option: " << (char)optopt
<< "\ntry: -h\n";
return EINVAL;
}
}
for (int i = 0; i < 10; i++) {
std::cout << "trestní oznámení\n";
}
}