I'm trying to provide completion candidates for mas (https://github.com/mas-cli/mas). A certain parameter accepts an ADAM ID, which is a UInt64 ID for an app from the App Store. I want to search through 3 different app properties (ADAM ID, Bundle ID, and Name) for installed apps, then offer as completion candidates all apps where any of the 3 aforementioned properties case-insensitively starts with the command-line word for which completions are being requested (let's call that "the word"). Once a candidate has been selected, I want to insert the ADAM ID into the command line in place of the word. e.g., say I have apps: ADAM ID: 123 Bundle ID: org.example.cool-app Name: Cool App Description: A really cool app ADAM ID: 456 Bundle ID: com.example.1app Name: 1App Description: One app to rule them all For simplicity, say my command is mas, and say it has only one parameter, which accepts only a single ADAM ID argument. If I tab at the end of the following command lines, I would like to see the respective offered candidates: $ mas 1 == Match ADAM ID == 123 -- Cool App: A really cool app == Match Name == 1App -- One app to rule them all $ mas c == Match Bundle ID == com.example.1app -- 1App: One app to rule them all == Match Name == Cool App -- A really cool app Note that I've prepended the Name followed by a colon & space before the Description iff the matching was for a property other than Name. This is a stylistic preference; if it cannot be easily achieved, I can prepend Name, colon & space to Description for all candidates, not just those that matched properties other than Name. After a candidate has been selected, the word should be replaced with the ADAM ID. e.g., tabbing at the end of the command line `mas o` would complete to Cool App because its Bundle ID (org.example.cool-app) starts with o & because no other ADAM ID, Bundle ID, or Name starts with o. Before tabbing, the command line should be: $ mas o After completing to Cool App by pressing tab, the above would be replaced by the following: $ mas 123 Assuming that I can supply the app info (ADAM ID, Bundle ID, Name & Description) in any format that would be required, how can I achieve my desired completion functionality, or as close as possible to it? (I might need to forgo certain cosmetic preferences, e.g., it might be difficult to include the Name in the candidate "label" iff the matched property isn't Name; maybe I cannot use `==` around group headers; maybe I cannot have a blank line between groups; etc.) Thanks for any help with this. Sent with Proton Mail secure email.
Attachment:
signature.asc
Description: OpenPGP digital signature