From 3aa4e243faa8198550cb2851cb6f0b9cbb293812 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Fri, 5 Jun 2020 18:42:20 +0200 Subject: tools: Add --version command line switch --- tools/idevicebackup.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'tools/idevicebackup.c') diff --git a/tools/idevicebackup.c b/tools/idevicebackup.c index c55301c..171ab7e 100644 --- a/tools/idevicebackup.c +++ b/tools/idevicebackup.c @@ -24,6 +24,8 @@ #include #endif +#define TOOL_NAME "idevicebackup" + #include #include #include @@ -606,7 +608,7 @@ static void do_post_notification(const char *notification) np_client_t np; if (!client) { - if (lockdownd_client_new_with_handshake(device, &client, "idevicebackup") != LOCKDOWN_E_SUCCESS) { + if (lockdownd_client_new_with_handshake(device, &client, TOOL_NAME) != LOCKDOWN_E_SUCCESS) { return; } } @@ -673,9 +675,10 @@ static void print_usage(int argc, char **argv) printf(" restore\tRestores a device backup from DIRECTORY.\n"); printf("\n"); printf("OPTIONS:\n"); - printf(" -d, --debug\t\tenable communication debugging\n"); printf(" -u, --udid UDID\ttarget specific device by UDID\n"); + printf(" -d, --debug\t\tenable communication debugging\n"); printf(" -h, --help\t\tprints usage information\n"); + printf(" -v, --version\t\tprints version information\n"); printf("\n"); printf("Homepage: <" PACKAGE_URL ">\n"); printf("Bug Reports: <" PACKAGE_BUGREPORT ">\n"); @@ -730,6 +733,10 @@ int main(int argc, char *argv[]) print_usage(argc, argv); return 0; } + else if (!strcmp(argv[i], "-v") || !strcmp(argv[i], "--version")) { + printf("%s %s\n", TOOL_NAME, PACKAGE_VERSION); + return 0; + } else if (!strcmp(argv[i], "backup")) { cmd = CMD_BACKUP; } @@ -792,7 +799,7 @@ int main(int argc, char *argv[]) } } - if (LOCKDOWN_E_SUCCESS != (ldret = lockdownd_client_new_with_handshake(device, &client, "idevicebackup"))) { + if (LOCKDOWN_E_SUCCESS != (ldret = lockdownd_client_new_with_handshake(device, &client, TOOL_NAME))) { printf("ERROR: Could not connect to lockdownd, error code %d\n", ldret); idevice_free(device); return -1; -- cgit v1.1-32-gdbae