Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow overriding preferences in CLI arguments. #251

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Commits on Sep 28, 2021

  1. replace load_default_document with a static value

    There's no reason we'd want multiple copies of the default settings,
    so the defaults can be easily extracted into a static variable to
    clean everything up a bit.
    oldaccountdeadname committed Sep 28, 2021
    Configuration menu
    Copy the full SHA
    fc42df5 View commit details
    Browse the repository at this point in the history

Commits on Sep 29, 2021

  1. don't wrap the preferences tree in an Option

    Instead, this patch uses Yaml::Null to indicate an empty options
    set. Doing things this way cuts down on around 50 lines of code
    by keeping most of the searching logic in `yaml-rust`'s domain.
    oldaccountdeadname committed Sep 29, 2021
    Configuration menu
    Copy the full SHA
    a557a6b View commit details
    Browse the repository at this point in the history
  2. extract precedence logic to private value function

    The `value` function computes the value associated with a given key
    for a given filename and extension. This was function was liberally
    to reduce the repeated logic in the code, and *slightly modifies
    behavior*, though in a backwards-compatible way. Some settings were
    only customizeable when declared at a global level in the config
    file, which may now be specified at the extension/filename level.
    This does not (yet) apply to some of the more complicated settings
    like `line_length_guide`: see the diff for mor details.
    oldaccountdeadname committed Sep 29, 2021
    Configuration menu
    Copy the full SHA
    2095083 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    11e2c92 View commit details
    Browse the repository at this point in the history
  4. move the in-memory theme value into the Yaml structure

    Rather than keeping the theme in a one-off structure entry, index
    it with the rest of the preferences values in a Yaml tree.
    
    This relies on a fork of `yaml-rust` which provides mutable acccess.
    oldaccountdeadname committed Sep 29, 2021
    Configuration menu
    Copy the full SHA
    ee52f8e View commit details
    Browse the repository at this point in the history

Commits on Sep 30, 2021

  1. Configuration menu
    Copy the full SHA
    ac5d2f2 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    a4926ee View commit details
    Browse the repository at this point in the history

Commits on Oct 2, 2021

  1. extract find_with_precendence

    Utilise `borrowed_or` in my yaml-rust fork to shorten the logic.
    oldaccountdeadname committed Oct 2, 2021
    Configuration menu
    Copy the full SHA
    4318601 View commit details
    Browse the repository at this point in the history
  2. Use value to simplify getters

    Applies to getters:
    + line_comment_prefix
    + syntax_definition_name
    oldaccountdeadname committed Oct 2, 2021
    Configuration menu
    Copy the full SHA
    ec0004e View commit details
    Browse the repository at this point in the history

Commits on Oct 23, 2021

  1. find line length guide with buffer's path

    This allows for the configuration to specify a line length guide
    depending on the file type, for instance, 80 characters everywhere, but
    72 in .git/COMMIT_EDITMSG.
    
    Note that this changes the Preferences public API, so there are a fair
    few modifications, including to unit tests.
    oldaccountdeadname committed Oct 23, 2021
    Configuration menu
    Copy the full SHA
    05b84d8 View commit details
    Browse the repository at this point in the history

Commits on Jan 18, 2022

  1. add --help message with more complex argument parsing

    This implements a simple argument parser that isolates 'direct'
    arguments (paths, etc) from `--key value` options, and treats the
    argument --help specially to display a usage message.
    
    For instance, the invocation `amp --key value src` would launch amp in
    the directory src with the option key set to value. Options are not
    currently used.
    
    This commit makes it impossible to pass a file beginning with `--` as a
    CLI argument: it will be assumed to be an option.
    oldaccountdeadname committed Jan 18, 2022
    Configuration menu
    Copy the full SHA
    bdd9667 View commit details
    Browse the repository at this point in the history
  2. allow overriding preferences in CLI arguments

    This allows specifying, for instance, `amp <file> --line_length_guide
    72` to override any value given in settings.
    
    This is done through a change in Application's constructor, allowing the
    provision of overrides. Because of this change, roughly 80-ish tests had
    to be modified to pass in empty overrides (thus the long diff).
    oldaccountdeadname committed Jan 18, 2022
    Configuration menu
    Copy the full SHA
    73c4909 View commit details
    Browse the repository at this point in the history
  3. Merge remote-tracking branch 'upstream/main' into cli-conf

    Cargo.lock had some merge conflicts. This manual merge used cargo to
    regenerate Cargo.lock (`rm Cargo.lock && cargo build`).
    oldaccountdeadname committed Jan 18, 2022
    Configuration menu
    Copy the full SHA
    d86e303 View commit details
    Browse the repository at this point in the history