Initial commit
This commit is contained in:
8
src/main.cpp
Normal file
8
src/main.cpp
Normal file
@@ -0,0 +1,8 @@
|
||||
// greetZ dolphin-emu and WIT team!
|
||||
#include "options.h"
|
||||
|
||||
int main(const int argc, char *argv[]) {
|
||||
parseOptions(argc, argv);
|
||||
|
||||
return 0;
|
||||
}
|
40
src/options.cpp
Normal file
40
src/options.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
#include <getopt.h>
|
||||
#include <iostream>
|
||||
#define VERSION "v0.1.0a"
|
||||
|
||||
void version() {
|
||||
std::cout << "rvz-convert " << VERSION << std::endl;
|
||||
}
|
||||
|
||||
void help() {
|
||||
std::cout << "Usage: rvz-convert [options] file" << std::endl;
|
||||
std::cout << "Options:\n\t-h --help\t\tDisplay this message" << std::endl;
|
||||
std::cout << "\t-v --version\tDisplay version information" << std::endl;
|
||||
}
|
||||
|
||||
void parseOptions(int argc, char *argv[]) {
|
||||
int c;
|
||||
int option_index = 0;
|
||||
|
||||
while (true) {
|
||||
static option options[] = {
|
||||
{"version",no_argument, nullptr, 'v'},
|
||||
{"help", no_argument, nullptr, 'h'},
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
c = getopt_long(argc, argv, "hv", options, &option_index);
|
||||
if (c == -1)
|
||||
break;
|
||||
switch (c) {
|
||||
case 'h':
|
||||
help();
|
||||
break;
|
||||
case 'v':
|
||||
version();
|
||||
break;
|
||||
default:
|
||||
help();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
8
src/options.h
Normal file
8
src/options.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#ifndef OPTIONS_H
|
||||
#define OPTIONS_H
|
||||
|
||||
void help();
|
||||
void version();
|
||||
void parseOptions(int argc, char *argv[]);
|
||||
|
||||
#endif //OPTIONS_H
|
Reference in New Issue
Block a user