From 9b80d56773334cc424ac932128d07bc066896808 Mon Sep 17 00:00:00 2001 From: sriniv27 Date: Mon, 8 Feb 2021 20:13:13 -0500 Subject: [PATCH] update docs --- docs/advanced.md | 11 ++++++----- features/overrides.feature | 20 ++++++++++++++------ features/steps/core.py | 7 ++++++- 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/docs/advanced.md b/docs/advanced.md index a778bd29..08ca095b 100644 --- a/docs/advanced.md +++ b/docs/advanced.md @@ -63,9 +63,9 @@ and can be edited with a plain text editor. ### Modifying Configurations from the Command line -You can override a configuration field for the current instance of `jrnl` using `--config-override CONFIG_KEY:CONFIG_VALUE` where `CONFIG_KEY` is a valid configuration field, specified in dot-notation and `CONFIG_VALUE` is the (valid) desired override value. +You can override a configuration field for the current instance of `jrnl` using `--config-override CONFIG_KEY CONFIG_VALUE` where `CONFIG_KEY` is a valid configuration field, specified in dot-notation and `CONFIG_VALUE` is the (valid) desired override value. -You can specify multiple overrides as a comma-separated list. +You can specify multiple overrides as multiple calls to `--config-override`. !!! note These overrides allow you to modify ***any*** field of your jrnl configuration. We trust that you know what you are doing. @@ -73,13 +73,14 @@ You can specify multiple overrides as a comma-separated list. ``` sh #Create an entry using the `stdin` prompt, for rapid logging -jrnl --config-override editor:"" +jrnl --config-override editor "" #Populate a project's log -jrnl --config-override journal:"$(git rev-parse --show-toplevel)/todo.txt" +jrnl --config-override journal "$(git rev-parse --show-toplevel)/todo.txt" #Pass multiple overrides -jrnl --config-override display_format:fancy,linewrap:20,colors.title:green +jrnl --config-override display_format fancy --config-override linewrap 20 \ +--config-override colors.title green ``` diff --git a/features/overrides.feature b/features/overrides.feature index 103a43ac..fec787e3 100644 --- a/features/overrides.feature +++ b/features/overrides.feature @@ -2,9 +2,17 @@ Feature: Implementing Runtime Overrides for Select Configuration Keys Scenario: Override configured editor with built-in input === editor:'' Given we use the config "tiny.yaml" - When we run jrnl with --config-override editor '' - Then the stdin prompt must be launched - + When we run "jrnl --config-override editor ''" + Then the stdin prompt should have been called + + Scenario: Postconfig commands with overrides + Given We use the config "basic_encrypted.yaml" + And we use the password "test" if prompted + When we run "jrnl --decrypt --config-override highlight false --config-override editor nano" + Then the runtime config should have "encrypt" set to "false" + And the runtime config should have "highlight" set to "false" + And the editor "nano" should have been called + @skip_win Scenario: Override configured linewrap with a value of 23 Given we use the config "tiny.yaml" @@ -30,13 +38,13 @@ Feature: Implementing Runtime Overrides for Select Configuration Keys @skip_win Scenario: Override color selections with runtime overrides Given we use the config "tiny.yaml" - When we run jrnl with -1 --config-override colors.body blue + When we run "jrnl -1 --config-override colors.body blue" Then the runtime config should have colors.body set to blue @skip_win Scenario: Apply multiple config overrides Given we use the config "tiny.yaml" - When we run jrnl with -1 --config-override colors.body green --config-override editor "nano" + When we run "jrnl -1 --config-override colors.body green --config-override editor 'nano'" Then the runtime config should have colors.body set to green And the runtime config should have editor set to nano @@ -44,7 +52,7 @@ Feature: Implementing Runtime Overrides for Select Configuration Keys @skip_win Scenario Outline: Override configured editor Given we use the config "tiny.yaml" - When we run jrnl with --config-override editor "" + When we run "jrnl --config-override editor \"\"" Then the editor should have been called Examples: Editor Commands | editor | diff --git a/features/steps/core.py b/features/steps/core.py index abf66bb4..1040d854 100644 --- a/features/steps/core.py +++ b/features/steps/core.py @@ -16,6 +16,7 @@ import keyring import toml import yaml +from yaml.loader import FullLoader import jrnl.time @@ -399,9 +400,13 @@ def run(context, command, text=""): if "cache_dir" in context and context.cache_dir is not None: cache_dir = os.path.join("features", "cache", context.cache_dir) command = command.format(cache_dir=cache_dir) + if "config_path" in context and context.config_path is not None: + with open(context.config_path, "r") as f: + cfg = yaml.load(f, Loader=FullLoader) + context.jrnl_config = cfg args = split_args(command) - + context.args = args[1:] def _mock_editor(command): context.editor_command = command tmpfile = command[-1]