Skip to content

Configuration / Config / Settings / Preferences system #838

@rgoldberg

Description

@rgoldberg

Overview

Implement a configuration / config / settings / preferences system.

  1. 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?
  2. The configuration must be stored somewhere. Options:
    1. Environment variables: No
      • Much too easy to be set incorrectly or to get messed up by other code / configs
    2. 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
  3. Users should be informed of new settings:
  4. 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

Metadata

Metadata

Assignees

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions