Add -b, --bundle-identifier command line switch to allow querying for bundle identifier

This commit is contained in:
Nikias Bassen
2023-02-11 00:35:52 +01:00
parent 39701a4c33
commit c50f53a7c2
2 changed files with 24 additions and 1 deletions
+3
View File
@@ -31,6 +31,9 @@ list apps installed on the device.
.RS
.B Additional options:
.TP
\-b <bundleID>
Only query for given bundle identifier (can be passed multiple times)
.TP
\-o list_user
list user apps only (apps installed by the user)
.B This is the default.
+21 -1
View File
@@ -120,6 +120,7 @@ int command_completed = 0;
int ignore_events = 0;
int err_occurred = 0;
int notified = 0;
plist_t bundle_ids = NULL;
static void print_apps_header()
{
@@ -400,6 +401,8 @@ static void print_usage(int argc, char **argv)
" -u, --udid UDID\tTarget specific device by UDID.\n"
" -n, --network\t\tConnect to network device.\n"
" -l, --list-apps\tList apps, possible options:\n"
" -b, --bundle-identifier\tOnly query for given bundle identifier\n"
" (can be passed multiple times)\n"
" -o list_user\t- list user apps only (this is the default)\n"
" -o list_system\t- list system apps only\n"
" -o list_all\t- list all types of apps\n"
@@ -448,12 +451,13 @@ static void parse_opts(int argc, char **argv)
{ "notify-wait", no_argument, NULL, 'w' },
{ "debug", no_argument, NULL, 'd' },
{ "version", no_argument, NULL, 'v' },
{ "bundle-identifier", required_argument, NULL, 'b' },
{ NULL, 0, NULL, 0 }
};
int c;
while (1) {
c = getopt_long(argc, argv, "hU:li:u:g:La:r:R:o:nwdv", longopts,
c = getopt_long(argc, argv, "hU:li:u:g:La:r:R:o:nwdvb:", longopts,
(int *) 0);
if (c == -1) {
break;
@@ -493,6 +497,17 @@ static void parse_opts(int argc, char **argv)
case 'n':
use_network = 1;
break;
case 'b':
if (!*optarg) {
printf("ERROR: bundle identifier must not be empty!\n");
print_usage(argc, argv);
exit(2);
}
if (bundle_ids == NULL) {
bundle_ids = plist_new_array();
}
plist_array_append_item(bundle_ids, plist_new_string(optarg));
break;
case 'l':
cmd = CMD_LIST_APPS;
break;
@@ -776,6 +791,10 @@ run_again:
free(opts);
}
if (bundle_ids) {
plist_dict_set_item(client_opts, "BundleIDs", plist_copy(bundle_ids));
}
if (!xml_mode) {
instproxy_client_options_set_return_attributes(client_opts,
"CFBundleIdentifier",
@@ -1499,6 +1518,7 @@ leave_cleanup:
free(appid);
free(options);
free(bundleidentifier);
plist_free(bundle_ids);
if (err_occurred && !res) {
res = 128;