mas-cli / mas

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

Support installation to subdirectories of `/Applications` #449

Open atommclain opened 2 years ago

atommclain commented 2 years ago

Is your feature request related to a problem? Please describe. Describe the solution you'd like It would be nice to support downloading apps to a custom path. Eg mas install 414568915 --path /Applications/Utilities

Describe alternatives you've considered I use a Brewfile with brew bundle to run mas, an alternative would be to create a script to manually move the applications to their desired location after calling brew bundle.

cd /Applications
mkdir -p /Applications/Utilities
mv Bakery.app /Applications/Utilities

Additional context Based on https://github.com/mas-cli/mas/issues/72 and https://github.com/mas-cli/mas/pull/376 I gather that supporting installation outside of the /Applications directory is not supported, but a subdirectory seems to work. If I install an app, then move it to a subdirectory of /Applications', it will still appear inmas list`.

phatblat commented 2 years ago

This is an interesting use case @atommclain. The Mac App Store doesn't support this, but apps can certainly be moved after installation.

Since you follow this practice, how has the Mac App Store treated these relocated apps? Do they get updated correctly? Are the updates installed to the same location, or do they get moved back up to /Applications?

In order for mas to support this, the install command would need support for an optional install path. Also, brew bundle would need the Brewfile syntax to support this optional path as well.

atommclain commented 2 years ago

Since you follow this practice, how has the Mac App Store treated these relocated apps? Do they get updated correctly? Are the updates installed to the same location, or do they get moved back up to /Applications?

I will verify and report back, but I've never had issues updating or applications getting moved up to this point.

In order for mas to support this, the install command would need support for an optional install path. Also, brew bundle would need the Brewfile syntax to support this optional path as well.

Perhaps I am misreading/misunderstanding, but I do believe that there is already support in the Brewfile syntax for passing in custom args. See example: cask "firefox", args: { appdir: "~/my-apps/Applications" } in https://github.com/Homebrew/homebrew-bundle. So perhaps it would just require updating the install command of mas?

phatblat commented 2 years ago

Ah! I didn't realize that brew bundle supported this appdir argument. In that light, yes, only the mas install command would need similar support.

atommclain commented 2 years ago

Just an update on this issue regarding:

Since you follow this practice, how has the Mac App Store treated these relocated apps? Do they get updated correctly? Are the updates installed to the same location, or do they get moved back up to /Applications?

I moved an application to a sub folder of /Applications/test and updated via mas-cli, the app was updated without issue.

rgoldberg commented 3 weeks ago

@atommclain In what ways does mas currently fail to support apps that have been moved to sub folders of /Applications?

What additional features do you want for apps in sub folders?

If you just want the ability to move apps, you can do that manually outside of mas. It will require root permissions to do so.

We could provide a command: mas paths <app-id> that would output the paths to all the instances of apps with the given app ID.

Or, once we supply json output with a --json switch, you could extract the paths from the JSON output of mas info <app-id> by piping to something like jq.

Under normal circumstances, there's only one path because there's only one instance of an app with a given app ID, but you could have multiple instances, so mas will return an array / list, normally only one element long.

Would that handle all that you want?