Use long command-line options
In addition to the short form (e.g. "-p"), add the long form ("--port").
This commit is contained in:
parent
60b2f2ca64
commit
213b721ff9
1 changed files with 8 additions and 2 deletions
|
@ -1,5 +1,6 @@
|
||||||
#include "scrcpy.h"
|
#include "scrcpy.h"
|
||||||
|
|
||||||
|
#include <getopt.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <libavformat/avformat.h>
|
#include <libavformat/avformat.h>
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
|
@ -12,9 +13,14 @@ struct args {
|
||||||
Uint16 maximum_size;
|
Uint16 maximum_size;
|
||||||
};
|
};
|
||||||
|
|
||||||
int parse_args(struct args *args, int argc, char *argv[]) {
|
static int parse_args(struct args *args, int argc, char *argv[]) {
|
||||||
|
static const struct option long_options[] = {
|
||||||
|
{"port", required_argument, NULL, 'p'},
|
||||||
|
{"max-size", required_argument, NULL, 'm'},
|
||||||
|
{NULL, 0, NULL, 0 },
|
||||||
|
};
|
||||||
int c;
|
int c;
|
||||||
while ((c = getopt(argc, argv, "p:m:")) != -1) {
|
while ((c = getopt_long(argc, argv, "p:m:", long_options, NULL)) != -1) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'p': {
|
case 'p': {
|
||||||
char *endptr;
|
char *endptr;
|
||||||
|
|
Loading…
Reference in a new issue