update docs

This commit is contained in:
sriniv27 2021-02-08 20:13:13 -05:00
parent ac819eb28f
commit 9b80d56773
3 changed files with 26 additions and 12 deletions

View file

@ -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
```

View file

@ -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 "<editor>"
When we run "jrnl --config-override editor \"<editor>\""
Then the editor <editor> should have been called
Examples: Editor Commands
| editor |

View file

@ -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]