print("Failed to match an application for '$input'\nAvailable applications are: ".join("\n",keys(%apps))."\n");
subusage()
{
print("Usage: $0 [-a|-d|-h] <search>\n\n".
"Simplified flatpak run script. Accepts a search word and will run the best-matching application, or provide a selection for multiple best-matches\n".
"\n".
" search\n".
" Term to search for in flatpak name or id. If omitted, all flatpaks will be provide as selections.\n".
" -a\n".
" Perform all search types and display all matches as options. As opposed to the 'best-match' method described below. Also include 'Platform' and 'Codecs' results.\n".
" -d\n".
" Print DEBUG information. Displays match information by type while searching.\n".
" -h\n".
" This menu.\n".
"\n".
"The 'best-match' search methods will be tried in order:\n".
" * Exact id match\n".
" * Exact name match\n".
" * Case-insensitive name match\n".
" * Exact id last stanza match\n".
" * Case-insensitive last id match\n".
" * Fuzzy name match\n".
" * Fuzzy id match\n".
"\n".
"Except when '-a' is used, flatpaks containing 'Platform' or 'Codecs' will be ignored.\n"
);
exit();
}
subchoice(@list)
{
return$list[0]if(scalar(@list)==1);
print("Multiple matches:\n");
for(my$i=1;$i<=scalar(@list);$i++){
print("$i : $list[$i-1]\n");
}
print("Enter your selection: [1-".scalar(@list)."]: ");