mas-cli / mas

:package: Mac App Store command line interface
MIT License
10.9k stars 275 forks source link

`upgrade`: avoid dialogs for running apps (either skip running, auto-answer, etc.) #398

Open jonathanlaniado opened 3 years ago

jonathanlaniado commented 3 years ago

I would like to run mas upgrade as a bash script on a normal cadence to keep my apps updated and healthy. Currently, I cannot keep this process automatic since the script attempts to download ALL apps. Is there any flag or option to select only non-running apps when using mas upgrade?

I would like to avoid having to hit Cancel every time and instead let the script try again later:

CleanShot 2021-06-15 at 16 12 27@2x
chris-araman commented 3 years ago

Similar to #282.

@jonathanlaniado, not today, though you could probably piece something together in your favorite shell.

Maybe it could be implemented as something along the lines of:

mas upgrade --if-running=<fail|kill|prompt>

The existing behavior is essentially prompt, by way of the private macOS frameworks mas invokes. For the fail and kill options, we'd need to enumerate all executables, dylibs, and frameworks in the existing bundle, and compare it against all loaded modules in all running tasks. I suspect that examing other processes would require privilege elevation (sudo), which limits scriptability.

An alternative might be to detect the opening of the UI prompt from the private frameworks and to inject input to respond according to the command line flag. That would probably also require app permissions or privilege elevation.

I don't see any straightforward solutions to this at the moment.