Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shell completion overhaul #678

Open
rgoldberg opened this issue Dec 12, 2024 · 0 comments
Open

Shell completion overhaul #678

rgoldberg opened this issue Dec 12, 2024 · 0 comments

Comments

@rgoldberg
Copy link
Contributor

rgoldberg commented Dec 12, 2024

mas 1.8.7+ uses Swift Argument Parser (aka SAP), which can generate shell completion scripts for bash, fish & zsh.

Scripts for mas would be written to stdout by running:

mas --generate-completion-script <bash | fish | zsh>

The completion scripts generated by the current version of SAP (1.5.0), however, suffer from many problems.

I have opened 2 issues in SAP. I've submitted a PR for the first, and am finishing a PR for the second:

If SAP does not merge & release the associated PRs quickly, mas can depend on a branch off main in an mas fork of SAP that contains the aforementioned 2 PRs.

Once all SAP improvements are ready:

  • remove the existing bash & fish completion scripts from git
  • setup mas to generate completion scripts for all 3 shells using SAP
  • generate all 3 scripts in:
    • Homebrew/core/mas formula
    • mas-cli/tap/mas formula
    • *.pkg installation process
    • any other installation process
  • document completion script generation in README.md
  • possibly create a new command / option to write scripts for all three shells (or maybe just one at a time based on an argument) to their proper locations to be loaded by their respective shell & used for completion.
  • discontinue app names as arguments for mas upgrade
    • remove AppLibrary.installedApps(named:)
  • Remove lucky after providing replacements #608
  • Offer subcommands as completions after mas help

Assuming that bundle IDs are supported as arguments optionally in place of app IDs (see #541; app IDs & bundle IDs will be collectively termed IDs), completion for IDs would work as follows:

For commands that work on installed apps:

If the current word contains all digits, match against installed app IDs, then offer them as completions, annotated with the associated app name & bundle ID.

Otherwise, match against installed bundle IDs, then offer them as completions, annotated with the associated app name & app ID.

Also, search the installed app names for the text of the current word. Offer the bundle ID as the completion for each result (ordered as per the response from Apple), each annotated with the app name & app ID.

The above completion candidates would be filtered as relevant to the current command. e.g., only IDs of outdated apps would be offered for mas upgrade.

For commands that work on apps that aren't installed:

Search the Apple iTunes Store Web API for the text of the current word. Offer the bundle ID as the completion for each result (ordered as per the response from Apple), each annotated with the app name & app ID.

Supersede:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant