meta_package_manager.managers.mas module¶
- class meta_package_manager.managers.mas.MAS[source]¶
Bases:
PackageManagermasdrives the Mac App Store from the command line.Packages are Mac App Store applications, keyed by the numeric adamID Apple assigns each title (the
idin an App Store link). mpm reads and writes that ID; the display name rides along only as a label.Every query reads
--jsonoutput, the supported programmatic interface since the>=7.0.0floor added--jsontolist,outdatedandsearch. It sidesteps the column-alignment ambiguities of the tabular listing, where an app name carrying parentheses or padding whitespace would derail a positional parser.Note
masprints one JSON object per app, concatenated rather than wrapped in an array, and leaves control characters (embedded newlines,U+2028) unescaped inside name and description strings (mas-cli/mas#1248). mpm decodes the buffer one object at a time withstrict=Falseso each object ends at its own closing brace instead of splitting on those bytes. The bug is fixed upstream for the (still unreleased)7.1.0, so this workaround can be retired once therequirementfloor rises to>=7.1.0.Note
masself-escalates: it asks for root itself when a store mutation needs it, so mpm never wrapsinstall,upgradeoruninstallin its ownsudo.Initialize
cli_errorslist.- name: str = 'Mac App Store'¶
Return package manager’s common name.
Default value is based on class name.
- homepage_url: str | None = 'https://github.com/mas-cli/mas'¶
Home page of the project, only used in documentation for reference.
- logo: str | None = 'appstore'¶
Slug of the brand mark standing for this manager in the documentation.
Names an SVG vendored under
docs/assets/managers/, whose provenance and license are recorded indocs/assets/managers/logos.yaml. Inlined at the top of the manager’s page bymeta_package_manager._docs; a manager leaving it unset keeps the page’s default package glyph.Several managers legitimately share one slug, either because they wrap the same upstream (
brewandcask) or because the tool has no mark of its own and its ecosystem’s stands in (aptunder Debian’s swirl,cargounder Rust’s gear). Documentation-only, likehomepage_url: no CLI output reads it.
- brewfile_entry_type: ClassVar[str | None] = 'mas'¶
Name of the Brewfile DSL entry type this manager maps to, or
Noneif the manager has no Brewfile equivalent.Set by the subset of managers Homebrew Bundle’s DSL covers, and consumed by
meta_package_manager.brewfilewhen rendering the output ofmpm dump --brewfile. Which manager maps to which entry is tabulated from these declarations in Snapshot and export, section “Brewfile”, where the export’s own quirks are documented too.
- platforms: frozenset[Platform] | Group | Platform | Iterable[Platform | Group] = frozenset({Platform(id='macos', name='macOS')})¶
List of platforms supported by the manager.
Allows for a mishmash of platforms and groups of platforms. Will be normalized into a
frozensetofPlatforminstances at instantiation.
- requirement: str | None = '>=7.0.0'¶
7.0.0 introduces the
--jsonflag onconfig,list,lookup/info,outdated&search. Parsing structured JSON output is the supported programmatic interface: it sidesteps the column-alignment ambiguities of the tabular output (app names containing parentheses or extra whitespace would break the previous regex-based parser).
- brewfile_entry(package)[source]¶
Emit the app’s display name, with its numeric adamID as the
id:keywordbrew bundleinstalls from.Returns
None(silently skip) for any package whose ID is not such a number: without it the entry cannot round-trip, and a half-brokenmas "Name"line would error at install time. See Snapshot and export, section “masentries”.
- property installed: Iterator[Package]¶
Fetch installed packages.
$ mas list --json {"adamID":1569813296,"bundleID":"com.1password.1password-safari","name":"1Password for Safari","version":"2.3.5"} {"adamID":1295203466,"bundleID":"com.microsoft.rdc.macos","name":"Microsoft Remote Desktop","version":"10.7.6"} {"adamID":409183694,"bundleID":"com.apple.iWork.Keynote","name":"Keynote","version":"12.0"}
- property outdated: Iterator[Package]¶
Fetch outdated packages.
$ mas outdated --json {"adamID":409183694,"name":"Keynote","newVersion":"12.0","version":"11.0"} {"adamID":1176895641,"name":"Spark","newVersion":"2.11.21","version":"2.11.20"}
- release_date(package_id)[source]¶
Publication timestamp of the latest release of an app, read from the App Store catalog.
mas lookup --jsonrelays the App Store’s own catalog record, whosecurrentVersionReleaseDateis stamped by the store when the version goes live after review, not by the app’s author, which is what makes it a sound cooldown clock. App Review already delays every release on its own, so the window mostly buys time between a version going live and a takedown.$ mas lookup 409183694 --json {"adamID":409183694,"bundleID":"com.apple.iWork.Keynote","currentVersionReleaseDate":"2024-04-02T17:19:42Z","name":"Keynote","version":"14.0"}
- search(query, extended, exact)[source]¶
Fetch matching packages.
Caution
Search does not support extended or exact matching. So we return the best subset of results and let
meta_package_manager.manager.PackageManager.refiltered_search()refine them.$ mas search python --json {"adamID":689176796,"name":"Python Runner","version":"1.3"} {"adamID":630736088,"name":"Learning Python","version":"1.0"} {"adamID":945397020,"name":"Run Python","version":"1.0"} {"adamID":1164498373,"name":"PythonGames","version":"1.0"} {"adamID":1400050251,"name":"Pythonic","version":"1.0.0"}
- install(package_id, version=None)[source]¶
Install one package.
$ mas install 945397020
- Return type:
- cli_names: tuple[str, ...] = ('mas',)¶
List of CLI names the package manager is known as.
This list of recognized CLI names is ordered by priority. That way we can influence the search of the right binary.
- ..hint::
This was helpful in the case of the Python transition from 2.x to 3.x, where multiple versions of the same executable were named
pythonorpython3.
By default, this property’s value is derived from the manager’s ID (see the
MetaPackageManager.__init__method above).
- id: str = 'mas'¶
Package manager’s ID.
Derived by defaults from the lower-cased class name in which underscores
_are replaced by dashes-.This ID must be unique among all package manager definitions and lower-case, as they’re used as feature flags for the mpm CLI.
- upgrade_one_cli(package_id, version=None)[source]¶
Generates the CLI to upgrade the provided package.
$ mas upgrade 945397020
- virtual: bool = False¶
Should we expose the package manager to the user?
Virtual package manager are just skeleton classes used to factorize code among managers of the same family.
- remove(package_id)[source]¶
Removes a package.
mas4.1.0+ requests root privileges itself when not already running as root, so we don’t pre-wrap the call insudo. This matches howinstallandupgradeare already invoked.$ mas uninstall 1494051017 Password: Uninstalled '/Applications/SimpleLogin.app' to '/Users/kde/.Trash/SimpleLogin.app'
- Return type: