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.
39 lines
728 B
39 lines
728 B
|
3 weeks ago
|
#include "options.hpp"
|
||
|
|
#include <fmt/core.h>
|
||
|
|
#include <unistd.h>
|
||
|
|
|
||
|
|
void print_usage() {
|
||
|
|
fmt::println("USAGE: bezos [-p PORT] [-h] -d deck.md");
|
||
|
|
}
|
||
|
|
|
||
|
|
Options parse_options(int argc, char* argv[]) {
|
||
|
|
int opt = 0;
|
||
|
|
Options result;
|
||
|
|
|
||
|
|
while((opt = getopt(argc, argv, "hp:d:")) != -1) {
|
||
|
|
switch(opt) {
|
||
|
|
case 'h':
|
||
|
|
print_usage();
|
||
|
|
return {.help=true};
|
||
|
|
break;
|
||
|
|
case 'p':
|
||
|
|
result.port = std::stoi(optarg);
|
||
|
|
break;
|
||
|
|
case 'd':
|
||
|
|
result.deck_given=true;
|
||
|
|
result.deck_file = optarg;
|
||
|
|
break;
|
||
|
|
default:
|
||
|
|
print_usage();
|
||
|
|
return {.error=true};
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
if(!result.deck_given) {
|
||
|
|
print_usage();
|
||
|
|
result.error = true;
|
||
|
|
}
|
||
|
|
|
||
|
|
return result;
|
||
|
|
}
|