Overview
Implement a configuration / config / settings / preferences system.
- https://github.com/apple/swift-configuration
- A command-line interface must be added to modify & to display settings; see below - Command-line flags like
--local-only should be rendered unnecessary
- If using flags, though,
--local-only should be renamed as people might consider USB or Thunderbolt drives to be local
- Maybe
--root-applications-folder-only? Something more concise?
- The configuration must be stored somewhere. Options:
- Environment variables: No
- Much too easy to be set incorrectly or to get messed up by other code / configs
- Config file: Yes
- A
UserDefaults plist: binary, XML, or JSON? Probably use binary
- mas will only run on macOS, so no need to worry about cross-platform issues
- The Swift
UserDefaults API will facilitate implementation
- Users should be informed of new settings:
- Settings would be namespaced via a
.-delimited hierarchy
Interface
Unless someone suggests a better interface: use mas config to set settings (it currently does not set settings; it only outputs various info about mas & system).
Will use subcommands instead of options for the various command lines unless someone convinces me otherwise.
- print setting:
print [<setting>…]:
- print given setting values one per line, like
<setting>: <value>
- if no settings specified, print all setting values
- default subcommand, so
mas config [<setting>…] is equivalent
- print only values = quiet?:
-q/--quiet and/or -v/--value/--value-only:
- print each value without its corresponding setting name, i.e.:
<value> instead of <setting>: <value>
- print values in the order of the
<setting> arguments, or alphabetically if no <setting>s were given
- set setting:
set (<setting> <value>)…:
- set each setting to its respective value
- normally accepts literal values but can accept flags that map to values:
- e.g.: for app search folder, accept
--all-root-applications-folders (equivalent to /Volumes/*/Applications)
- use the standalone
-- option/flag terminator before a literal value that begins with --
- e.g.:
mas config -s setting-name -- --literal-value
- add to setting:
add (<setting> <value>)…:
- add each value to its respective setting:
- e.g., add a path to the app search folder path list
- print info about setting:
info [<setting>…]:
- prints explanatory text, default value, and possibly current value for each given setting
- if no settings are specified, print info for all settings
- print default setting value:
default [<setting>…]
- print given setting default values one per line, like
<setting>: <value>
- if no settings specified, print all setting default values
- print only values = quiet?:
-q/--quiet and/or -v/--value/--value-only:
- print each value without its corresponding setting name, i.e.:
<value> instead of <setting>: <value>
- print values in the order of the
<setting> arguments, or alphabetically if no <setting>s were given
- reset setting:
reset [<setting>…]:
- no
<setting>s: prompt to reset all settings to default (--force avoids prompt)
<setting>s: reset <setting> to default value
- remove value from setting:
remove (<setting> <value>)…:
- remove
<value> from <setting> list
- if all values have been removed, the setting reverts to its default value
- export setting:
export [<setting>…]:
- print command lines to set each setting to its current value, one setting per command line
- if no settings are specified, print commands for all settings
- if a setting is non-defaulted, print a
set command line
- if a setting is defaulted, print a
reset command line
-c/--concise: As necessary:
- print one
set command line to set all non-defaulted settings to their current values
- print one
reset command line to reset all defaulted settings
-l/--literal-defaults: use set instead of reset for defaulted settings
-d/--defaults-only?: print command lines to set each setting to its current literal default value (to compare different defaults across mas versions)
- excluded settings
excluded:
- print settings that are excluded from being printed by commands without explicit
<setting> arguments
--all for other commands will include excluded settings
excluded would have all the other config subcommands as subcommands (excluded would obviously not be a subcommand of excluded)
- default excluded settings might include dismissed tips, but maybe not the tip-dismissal setting
Overview
Implement a configuration / config / settings / preferences system.
--local-onlyshould be rendered unnecessary--local-onlyshould be renamed as people might consider USB or Thunderbolt drives to be local--root-applications-folder-only? Something more concise?UserDefaultsplist: binary, XML, or JSON? Probably use binaryUserDefaultsAPI will facilitate implementationmas helpoutputREADME.md.-delimited hierarchyInterface
Unless someone suggests a better interface: use
mas configto set settings (it currently does not set settings; it only outputs various info about mas & system).Will use subcommands instead of options for the various command lines unless someone convinces me otherwise.
print [<setting>…]:<setting>: <value>mas config [<setting>…]is equivalent-q/--quietand/or-v/--value/--value-only:<value>instead of<setting>: <value><setting>arguments, or alphabetically if no<setting>s were givenset (<setting> <value>)…:--all-root-applications-folders(equivalent to/Volumes/*/Applications)--option/flag terminator before a literal value that begins with--mas config -s setting-name -- --literal-valueadd (<setting> <value>)…:info [<setting>…]:default [<setting>…]<setting>: <value>-q/--quietand/or-v/--value/--value-only:<value>instead of<setting>: <value><setting>arguments, or alphabetically if no<setting>s were givenreset [<setting>…]:<setting>s: prompt to reset all settings to default (--forceavoids prompt)<setting>s: reset<setting>to default valueremove (<setting> <value>)…:<value>from<setting>listexport [<setting>…]:setcommand lineresetcommand line-c/--concise: As necessary:setcommand line to set all non-defaulted settings to their current valuesresetcommand line to reset all defaulted settings-l/--literal-defaults: usesetinstead ofresetfor defaulted settings-d/--defaults-only?: print command lines to set each setting to its current literal default value (to compare different defaults across mas versions)excluded:<setting>arguments--allfor other commands will include excluded settingsexcludedwould have all the other config subcommands as subcommands (excludedwould obviously not be a subcommand ofexcluded)