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.
44 lines
913 B
44 lines
913 B
#include "options.hpp"
|
|
#include <fmt/core.h>
|
|
#include <unistd.h>
|
|
|
|
void print_usage() {
|
|
fmt::println("USAGE: bezos [-W width] [-H height] [-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:W:H:")) != -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;
|
|
case 'W':
|
|
result.pres_size.x = std::stoi(optarg);
|
|
break;
|
|
case 'H':
|
|
result.pres_size.y = std::stoi(optarg);
|
|
break;
|
|
default:
|
|
print_usage();
|
|
return {.error=true};
|
|
}
|
|
}
|
|
|
|
if(!result.deck_given) {
|
|
print_usage();
|
|
result.error = true;
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|