Expose application version

Expose scrcpy version via -v or --version.
This commit is contained in:
Romain Vimont 2018-02-07 12:37:53 +01:00
parent 8d30d40b79
commit 9f6464acff
2 changed files with 19 additions and 1 deletions

View file

@ -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')

View file

@ -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()) {