diff options
Diffstat (limited to 'tools/idevicename.c')
-rw-r--r-- | tools/idevicename.c | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/tools/idevicename.c b/tools/idevicename.c index 97bf2d4..69b76f6 100644 --- a/tools/idevicename.c +++ b/tools/idevicename.c | |||
@@ -37,21 +37,24 @@ | |||
37 | #include <libimobiledevice/libimobiledevice.h> | 37 | #include <libimobiledevice/libimobiledevice.h> |
38 | #include <libimobiledevice/lockdown.h> | 38 | #include <libimobiledevice/lockdown.h> |
39 | 39 | ||
40 | static void print_usage(void) | 40 | static void print_usage(int argc, char** argv, int is_error) |
41 | { | 41 | { |
42 | printf("Usage: idevicename [OPTIONS] [NAME]\n"); | 42 | char *name = strrchr(argv[0], '/'); |
43 | printf("\n"); | 43 | fprintf(is_error ? stderr : stdout, "Usage: %s [OPTIONS] [NAME]\n", (name ? name + 1: argv[0])); |
44 | printf("Display the device name or set it to NAME if specified.\n"); | 44 | fprintf(is_error ? stderr : stdout, |
45 | printf("\n"); | 45 | "\n" |
46 | printf("OPTIONS:\n"); | 46 | "Display the device name or set it to NAME if specified.\n" |
47 | printf(" -u, --udid UDID\ttarget specific device by UDID\n"); | 47 | "\n" |
48 | printf(" -n, --network\t\tconnect to network device\n"); | 48 | "OPTIONS:\n" |
49 | printf(" -d, --debug\t\tenable communication debugging\n"); | 49 | " -u, --udid UDID target specific device by UDID\n" |
50 | printf(" -h, --help\t\tprint usage information\n"); | 50 | " -n, --network connect to network device\n" |
51 | printf(" -v, --version\t\tprint version information\n"); | 51 | " -d, --debug enable communication debugging\n" |
52 | printf("\n"); | 52 | " -h, --help print usage information\n" |
53 | printf("Homepage: <" PACKAGE_URL ">\n"); | 53 | " -v, --version print version information\n" |
54 | printf("Bug Reports: <" PACKAGE_BUGREPORT ">\n"); | 54 | "\n" |
55 | "Homepage: <" PACKAGE_URL ">\n" | ||
56 | "Bug Reports: <" PACKAGE_BUGREPORT ">\n" | ||
57 | ); | ||
55 | } | 58 | } |
56 | 59 | ||
57 | int main(int argc, char** argv) | 60 | int main(int argc, char** argv) |
@@ -78,7 +81,7 @@ int main(int argc, char** argv) | |||
78 | case 'u': | 81 | case 'u': |
79 | if (!*optarg) { | 82 | if (!*optarg) { |
80 | fprintf(stderr, "ERROR: UDID must not be empty!\n"); | 83 | fprintf(stderr, "ERROR: UDID must not be empty!\n"); |
81 | print_usage(); | 84 | print_usage(argc, argv, 1); |
82 | exit(2); | 85 | exit(2); |
83 | } | 86 | } |
84 | udid = optarg; | 87 | udid = optarg; |
@@ -87,7 +90,7 @@ int main(int argc, char** argv) | |||
87 | use_network = 1; | 90 | use_network = 1; |
88 | break; | 91 | break; |
89 | case 'h': | 92 | case 'h': |
90 | print_usage(); | 93 | print_usage(argc, argv, 0); |
91 | return 0; | 94 | return 0; |
92 | case 'd': | 95 | case 'd': |
93 | idevice_set_debug_level(1); | 96 | idevice_set_debug_level(1); |
@@ -96,7 +99,7 @@ int main(int argc, char** argv) | |||
96 | printf("%s %s\n", TOOL_NAME, PACKAGE_VERSION); | 99 | printf("%s %s\n", TOOL_NAME, PACKAGE_VERSION); |
97 | return 0; | 100 | return 0; |
98 | default: | 101 | default: |
99 | print_usage(); | 102 | print_usage(argc, argv, 1); |
100 | return 2; | 103 | return 2; |
101 | } | 104 | } |
102 | } | 105 | } |
@@ -105,8 +108,8 @@ int main(int argc, char** argv) | |||
105 | argv += optind; | 108 | argv += optind; |
106 | 109 | ||
107 | if (argc > 1) { | 110 | if (argc > 1) { |
108 | print_usage(); | 111 | print_usage(argc, argv, 1); |
109 | return -1; | 112 | return 2; |
110 | } | 113 | } |
111 | 114 | ||
112 | idevice_t device = NULL; | 115 | idevice_t device = NULL; |