mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-20 04:58:32 +02:00
move overrides earlier in the execution
use existing configs instead of custom make format clean up imports
This commit is contained in:
parent
c8e09b023f
commit
1df4b74e53
5 changed files with 23 additions and 27 deletions
|
@ -1,8 +0,0 @@
|
|||
journals:
|
||||
default: features/journals/simple.journal
|
||||
colors:
|
||||
body: none
|
||||
title: green
|
||||
editor: "vim"
|
||||
encrypt: false
|
||||
#
|
|
@ -1,7 +1,8 @@
|
|||
Feature: Implementing Runtime Overrides for Select Configuration Keys
|
||||
|
||||
Scenario: Override configured editor with built-in input === editor:''
|
||||
Given we use the config "tiny.yaml"
|
||||
Given we use the config "basic_encrypted.yaml"
|
||||
And we use the password "test" if prompted
|
||||
When we run "jrnl --config-override editor ''"
|
||||
Then the stdin prompt should have been called
|
||||
|
||||
|
@ -11,11 +12,12 @@ Feature: Implementing Runtime Overrides for Select Configuration Keys
|
|||
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
|
||||
And the editor "N/A" should have been called
|
||||
|
||||
@skip_win
|
||||
Scenario: Override configured linewrap with a value of 23
|
||||
Given we use the config "tiny.yaml"
|
||||
Given we use the config "simple.yaml"
|
||||
And we use the password "test" if prompted
|
||||
When we run "jrnl -2 --config-override linewrap 23 --format fancy"
|
||||
Then the output should be
|
||||
|
||||
|
@ -37,13 +39,15 @@ Feature: Implementing Runtime Overrides for Select Configuration Keys
|
|||
|
||||
@skip_win
|
||||
Scenario: Override color selections with runtime overrides
|
||||
Given we use the config "tiny.yaml"
|
||||
Given we use the config "basic_encrypted.yaml"
|
||||
And we use the password "test" if prompted
|
||||
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"
|
||||
Given we use the config "basic_encrypted.yaml"
|
||||
And we use the password "test" if prompted
|
||||
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
|
||||
|
@ -51,11 +55,12 @@ 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 --config-override editor \"<editor>\""
|
||||
Given we use the config "basic_encrypted.yaml"
|
||||
And we use the password "test" if prompted
|
||||
When we run "jrnl --config-override editor '<editor>'"
|
||||
Then the editor <editor> should have been called
|
||||
Examples: Editor Commands
|
||||
| editor |
|
||||
| nano |
|
||||
| vi -c startinsert |
|
||||
| code -w - |
|
||||
| code -w |
|
||||
|
|
|
@ -407,6 +407,7 @@ def run(context, command, text=""):
|
|||
|
||||
args = split_args(command)
|
||||
context.args = args[1:]
|
||||
|
||||
def _mock_editor(command):
|
||||
context.editor_command = command
|
||||
tmpfile = command[-1]
|
||||
|
|
|
@ -1,17 +1,14 @@
|
|||
from jrnl.jrnl import run
|
||||
from jrnl.os_compat import split_args
|
||||
from unittest import mock
|
||||
|
||||
# from __future__ import with_statement
|
||||
from jrnl.args import parse_args
|
||||
import os
|
||||
from behave import given, when, then
|
||||
import yaml
|
||||
from yaml.loader import FullLoader
|
||||
from behave import given, then
|
||||
|
||||
import jrnl
|
||||
|
||||
from features.steps.core import _mock_time_parse
|
||||
from features.steps.core import _mock_getpass, _mock_time_parse
|
||||
|
||||
|
||||
@given("we use the config {config_file}")
|
||||
|
|
11
jrnl/jrnl.py
11
jrnl/jrnl.py
|
@ -38,6 +38,12 @@ def run(args):
|
|||
try:
|
||||
config = install.load_or_install_jrnl()
|
||||
original_config = config.copy()
|
||||
|
||||
# Apply config overrides
|
||||
overrides = args.config_override
|
||||
if overrides:
|
||||
config = apply_overrides(overrides, config)
|
||||
|
||||
args = get_journal_name(args, config)
|
||||
config = scope_config(config, args.journal_name)
|
||||
except UserAbort as err:
|
||||
|
@ -50,11 +56,6 @@ def run(args):
|
|||
args=args, config=config, original_config=original_config
|
||||
)
|
||||
|
||||
# Apply config overrides
|
||||
overrides = args.config_override
|
||||
if overrides:
|
||||
config = apply_overrides(overrides, config)
|
||||
|
||||
# --- All the standalone commands are now done --- #
|
||||
|
||||
# Get the journal we're going to be working with
|
||||
|
|
Loading…
Add table
Reference in a new issue