summaryrefslogtreecommitdiffstats
path: root/tools/idevicedebug.c
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2022-04-30 13:31:20 +0200
committerGravatar Nikias Bassen2022-04-30 13:31:20 +0200
commit6cb13f9e6d3939930aecf91d8e23d1896a3b92e5 (patch)
tree371e4676ac914d9eef6bb4cfc0b5b6dc6f27da4f /tools/idevicedebug.c
parent3b5cad28fabb236e05b8fff82fab5098127aa2bb (diff)
downloadlibimobiledevice-6cb13f9e6d3939930aecf91d8e23d1896a3b92e5.tar.gz
libimobiledevice-6cb13f9e6d3939930aecf91d8e23d1896a3b92e5.tar.bz2
tools: Use getopt for option parsing in all tools
Diffstat (limited to 'tools/idevicedebug.c')
-rw-r--r--tools/idevicedebug.c39
1 files changed, 19 insertions, 20 deletions
diff --git a/tools/idevicedebug.c b/tools/idevicedebug.c
index 01551a2..fbb6c3e 100644
--- a/tools/idevicedebug.c
+++ b/tools/idevicedebug.c
@@ -177,27 +177,26 @@ static debugserver_error_t debugserver_client_handle_response(debugserver_client
static void print_usage(int argc, char **argv, int is_error)
{
- char *name = NULL;
- name = strrchr(argv[0], '/');
+ char *name = strrchr(argv[0], '/');
fprintf(is_error ? stderr : stdout, "Usage: %s [OPTIONS] COMMAND\n", (name ? name + 1: argv[0]));
fprintf(is_error ? stderr : stdout,
- "\n" \
- "Interact with the debugserver service of a device.\n" \
- "\n" \
- "Where COMMAND is one of:\n" \
- " run BUNDLEID [ARGS...]\trun app with BUNDLEID and optional ARGS on device.\n" \
- " kill BUNDLEID\tkill app with BUNDLEID\n" \
- "\n" \
- "The following OPTIONS are accepted:\n" \
- " -u, --udid UDID\ttarget specific device by UDID\n" \
- " -n, --network\t\tconnect to network device\n" \
- " --detach\t\tdetach from app after launch, keeping it running\n" \
- " -e, --env NAME=VALUE\tset environment variable NAME to VALUE\n" \
- " -d, --debug\t\tenable communication debugging\n" \
- " -h, --help\t\tprints usage information\n" \
- " -v, --version\t\tprints version information\n" \
- "\n" \
- "Homepage: <" PACKAGE_URL ">\n" \
+ "\n"
+ "Interact with the debugserver service of a device.\n"
+ "\n"
+ "Where COMMAND is one of:\n"
+ " run BUNDLEID [ARGS...] run app with BUNDLEID and optional ARGS on device.\n"
+ " kill BUNDLEID kill app with BUNDLEID\n"
+ "\n"
+ "The following OPTIONS are accepted:\n"
+ " -u, --udid UDID target specific device by UDID\n"
+ " -n, --network connect to network device\n"
+ " --detach detach from app after launch, keeping it running\n"
+ " -e, --env NAME=VALUE set environment variable NAME to VALUE\n"
+ " -d, --debug enable communication debugging\n"
+ " -h, --help prints usage information\n"
+ " -v, --version prints version information\n"
+ "\n"
+ "Homepage: <" PACKAGE_URL ">\n"
"Bug Reports: <" PACKAGE_BUGREPORT ">\n"
);
}
@@ -294,13 +293,13 @@ int main(int argc, char *argv[])
break;
}
}
-
argc -= optind;
argv += optind;
if (argc < 1) {
fprintf(stderr, "ERROR: Missing command.\n");
print_usage(argc+optind, argv-optind, 1);
+ return 2;
}
if (!strcmp(argv[0], "run")) {