diff --git a/app/meson.build b/app/meson.build index e3ee90b9..b1606720 100644 --- a/app/meson.build +++ b/app/meson.build @@ -32,6 +32,9 @@ dependencies = [ conf = configuration_data() +# the version, updated on release +conf.set_quoted('SCRCPY_VERSION', '0.1') + # the default client TCP port for the "adb reverse" tunnel # overridden by option --port conf.set('DEFAULT_LOCAL_PORT', '27183') diff --git a/app/src/main.c b/app/src/main.c index 4fe4e9a9..1d2259b9 100644 --- a/app/src/main.c +++ b/app/src/main.c @@ -10,6 +10,7 @@ struct args { const char *serial; SDL_bool help; + SDL_bool version; Uint16 port; Uint16 max_size; Uint32 bit_rate; @@ -43,6 +44,9 @@ static void usage(const char *arg0) { " Set the TCP port the client listens on.\n" " Default is %d.\n" "\n" + " -v, --version\n" + " Print the version of scrcpy.\n" + "\n" "Shortcuts:\n" "\n" " Ctrl+f\n" @@ -89,15 +93,20 @@ static int parse_args(struct args *args, int argc, char *argv[]) { {"port", required_argument, NULL, 'p'}, {"max-size", required_argument, NULL, 'm'}, {"bit-rate", required_argument, NULL, 'b'}, + {"version", no_argument, NULL, 'v'}, {NULL, 0, NULL, 0 }, }; int c; - while ((c = getopt_long(argc, argv, "hp:m:b:", long_options, NULL)) != -1) { + while ((c = getopt_long(argc, argv, "hvp:m:b:", long_options, NULL)) != -1) { switch (c) { case 'h': { args->help = SDL_TRUE; break; } + case 'v': { + args->version = SDL_TRUE; + break; + } case 'p': { char *endptr; if (*optarg == '\0') { @@ -184,6 +193,7 @@ int main(int argc, char *argv[]) { struct args args = { .serial = NULL, .help = SDL_FALSE, + .version = SDL_FALSE, .port = DEFAULT_LOCAL_PORT, .max_size = DEFAULT_MAX_SIZE, .bit_rate = DEFAULT_BIT_RATE, @@ -198,6 +208,11 @@ int main(int argc, char *argv[]) { return 0; } + if (args.version) { + fprintf(stderr, "scrcpy v%s\n", SCRCPY_VERSION); + return 0; + } + av_register_all(); if (avformat_network_init()) {