mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-20 13:08:31 +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
|
Feature: Implementing Runtime Overrides for Select Configuration Keys
|
||||||
|
|
||||||
Scenario: Override configured editor with built-in input === editor:''
|
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 ''"
|
When we run "jrnl --config-override editor ''"
|
||||||
Then the stdin prompt should have been called
|
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"
|
When we run "jrnl --decrypt --config-override highlight false --config-override editor nano"
|
||||||
Then the runtime config should have "encrypt" set to "false"
|
Then the runtime config should have "encrypt" set to "false"
|
||||||
And the runtime config should have "highlight" 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
|
@skip_win
|
||||||
Scenario: Override configured linewrap with a value of 23
|
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"
|
When we run "jrnl -2 --config-override linewrap 23 --format fancy"
|
||||||
Then the output should be
|
Then the output should be
|
||||||
|
|
||||||
|
@ -37,13 +39,15 @@ Feature: Implementing Runtime Overrides for Select Configuration Keys
|
||||||
|
|
||||||
@skip_win
|
@skip_win
|
||||||
Scenario: Override color selections with runtime overrides
|
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"
|
When we run "jrnl -1 --config-override colors.body blue"
|
||||||
Then the runtime config should have colors.body set to blue
|
Then the runtime config should have colors.body set to blue
|
||||||
|
|
||||||
@skip_win
|
@skip_win
|
||||||
Scenario: Apply multiple config overrides
|
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'"
|
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
|
Then the runtime config should have colors.body set to green
|
||||||
And the runtime config should have editor set to nano
|
And the runtime config should have editor set to nano
|
||||||
|
@ -51,11 +55,12 @@ Feature: Implementing Runtime Overrides for Select Configuration Keys
|
||||||
|
|
||||||
@skip_win
|
@skip_win
|
||||||
Scenario Outline: Override configured editor
|
Scenario Outline: Override configured editor
|
||||||
Given we use the config "tiny.yaml"
|
Given we use the config "basic_encrypted.yaml"
|
||||||
When we run "jrnl --config-override editor \"<editor>\""
|
And we use the password "test" if prompted
|
||||||
|
When we run "jrnl --config-override editor '<editor>'"
|
||||||
Then the editor <editor> should have been called
|
Then the editor <editor> should have been called
|
||||||
Examples: Editor Commands
|
Examples: Editor Commands
|
||||||
| editor |
|
| editor |
|
||||||
| nano |
|
| nano |
|
||||||
| vi -c startinsert |
|
| vi -c startinsert |
|
||||||
| code -w - |
|
| code -w |
|
||||||
|
|
|
@ -407,6 +407,7 @@ def run(context, command, text=""):
|
||||||
|
|
||||||
args = split_args(command)
|
args = split_args(command)
|
||||||
context.args = args[1:]
|
context.args = args[1:]
|
||||||
|
|
||||||
def _mock_editor(command):
|
def _mock_editor(command):
|
||||||
context.editor_command = command
|
context.editor_command = command
|
||||||
tmpfile = command[-1]
|
tmpfile = command[-1]
|
||||||
|
|
|
@ -1,17 +1,14 @@
|
||||||
from jrnl.jrnl import run
|
from jrnl.jrnl import run
|
||||||
from jrnl.os_compat import split_args
|
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
# from __future__ import with_statement
|
# from __future__ import with_statement
|
||||||
from jrnl.args import parse_args
|
from jrnl.args import parse_args
|
||||||
import os
|
import os
|
||||||
from behave import given, when, then
|
from behave import given, then
|
||||||
import yaml
|
|
||||||
from yaml.loader import FullLoader
|
|
||||||
|
|
||||||
import jrnl
|
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}")
|
@given("we use the config {config_file}")
|
||||||
|
|
11
jrnl/jrnl.py
11
jrnl/jrnl.py
|
@ -38,6 +38,12 @@ def run(args):
|
||||||
try:
|
try:
|
||||||
config = install.load_or_install_jrnl()
|
config = install.load_or_install_jrnl()
|
||||||
original_config = config.copy()
|
original_config = config.copy()
|
||||||
|
|
||||||
|
# Apply config overrides
|
||||||
|
overrides = args.config_override
|
||||||
|
if overrides:
|
||||||
|
config = apply_overrides(overrides, config)
|
||||||
|
|
||||||
args = get_journal_name(args, config)
|
args = get_journal_name(args, config)
|
||||||
config = scope_config(config, args.journal_name)
|
config = scope_config(config, args.journal_name)
|
||||||
except UserAbort as err:
|
except UserAbort as err:
|
||||||
|
@ -50,11 +56,6 @@ def run(args):
|
||||||
args=args, config=config, original_config=original_config
|
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 --- #
|
# --- All the standalone commands are now done --- #
|
||||||
|
|
||||||
# Get the journal we're going to be working with
|
# Get the journal we're going to be working with
|
||||||
|
|
Loading…
Add table
Reference in a new issue