MacOS – How to update App Store application from command line

automationcommand linemac-appstoremacos

I would like to force an update of App Store applications from the command line.

How can I do this?

Best Answer

Apple doesn't supply a command line helper or any scriptable cocoa classes you can latch on to for automation. Unlike the overall software update, which allows updates and installs out of the box, you can script the process of clicking buttons with a mouse using Automator.

However, the app store has been reverse engineered and released open source as well as a binary form:

The install is quick and it appears to be quite reliable on the current version of OS X 10.11:

brew install argon/mas/mas 

With the source released, I would expect some other implementations of this tool to pop up, perhaps even one scripted with python.

If someone is logged into the mac (windowmanager is running), you can use Automator and the "watch me do" function to automate updates and storing your store password in the script fairly insecurely.

Here are two tutorials to get you started if this meets your needs.

http://www.tuaw.com/2009/01/19/mac-automation-creating-watch-me-do-workflows/

http://automator.us/leopard/features/virtual-user.html

Once you have a working script, you can use the command line open command to kick it off.

If the App Store app ever exposes that function to scripting you will have more options from the command line. It would be easy to use sdef, sdp and gen_bridge_metadata to dump the entire scriptable dictionary and script things using ruby from the command line, but at present the best option would be to use the mas command line tool.