mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-10 16:48:31 +02:00
Make journal selection behavior more consistent when there's a colon with no date (#1164)
This commit is contained in:
parent
ac0c49918d
commit
ea845a8408
2 changed files with 26 additions and 4 deletions
|
@ -29,6 +29,20 @@ Feature: Multiple journals
|
||||||
And journal "work" should have 1 entry
|
And journal "work" should have 1 entry
|
||||||
And journal "work" should contain "2012-07-23"
|
And journal "work" should contain "2012-07-23"
|
||||||
|
|
||||||
|
Scenario: Write to specified journal without a timestamp but with colon
|
||||||
|
Given we use the config "multiple.yaml"
|
||||||
|
When we run "jrnl work : a long day in the office"
|
||||||
|
Then journal "default" should have 2 entries
|
||||||
|
And journal "work" should have 1 entry
|
||||||
|
And journal "work" should contain "a long day in the office"
|
||||||
|
|
||||||
|
Scenario: Write to specified journal without a timestamp but with colon
|
||||||
|
Given we use the config "multiple.yaml"
|
||||||
|
When we run "jrnl work: a long day in the office"
|
||||||
|
Then journal "default" should have 2 entries
|
||||||
|
And journal "work" should have 1 entry
|
||||||
|
And journal "work" should contain "a long day in the office"
|
||||||
|
|
||||||
Scenario: Create new journals as required
|
Scenario: Create new journals as required
|
||||||
Given we use the config "multiple.yaml"
|
Given we use the config "multiple.yaml"
|
||||||
Then journal "ideas" should not exist
|
Then journal "ideas" should not exist
|
||||||
|
|
|
@ -138,10 +138,18 @@ def update_config(config, new_config, scope, force_local=False):
|
||||||
|
|
||||||
def get_journal_name(args, config):
|
def get_journal_name(args, config):
|
||||||
args.journal_name = DEFAULT_JOURNAL_KEY
|
args.journal_name = DEFAULT_JOURNAL_KEY
|
||||||
if args.text and args.text[0] in config["journals"]:
|
|
||||||
args.journal_name = args.text[0]
|
# The first arg might be a journal name
|
||||||
|
if args.text:
|
||||||
|
potential_journal_name = args.text[0]
|
||||||
|
if potential_journal_name[-1] == ":":
|
||||||
|
potential_journal_name = potential_journal_name[0:-1]
|
||||||
|
|
||||||
|
if potential_journal_name in config["journals"]:
|
||||||
|
args.journal_name = potential_journal_name
|
||||||
args.text = args.text[1:]
|
args.text = args.text[1:]
|
||||||
elif DEFAULT_JOURNAL_KEY not in config["journals"]:
|
|
||||||
|
if args.journal_name not in config["journals"]:
|
||||||
print("No default journal configured.", file=sys.stderr)
|
print("No default journal configured.", file=sys.stderr)
|
||||||
print(list_journals(config), file=sys.stderr)
|
print(list_journals(config), file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
Loading…
Add table
Reference in a new issue