mas-cli / mas-cli/mas

Configuration / Config / Settings / Preferences system

Open
#838 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature
Dominant language
Swift
Stars
12.4k
Forks
299
Avg merge
1d 2h
Merged PRs (30d)
1

Description

Overview

Implement a configuration / config / settings / preferences system.

  1. https://github.com/apple/swift-configuration
  2. 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?
  3. The configuration must be stored somewhere. Options:
    1. Environment variables: Probably
      • 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
      • XDG?
        • $XDG_CONFIG_HOME
  4. Users should be informed of new settings:
  5. 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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no implementation files or tests; start by reviewing the existing mas config command and the linked issue #839 before choosing a configuration design. Done means the agreed configuration interface and storage are implemented, with settings documented in mas help and README.md.

Written by the indexing model from the issue text.

Assessment

Tech stack
macos, swift
Domain
cli, documentation
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.