mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-10 08:38:32 +02:00
Fix for #322
This commit is contained in:
parent
ca76077e09
commit
07fbf73dee
4 changed files with 13 additions and 22 deletions
|
@ -18,7 +18,7 @@ The configuration file is a simple JSON file with the following options and can
|
|||
- ``journals``
|
||||
paths to your journal files
|
||||
- ``editor``
|
||||
if set, executes this command to launch an external editor for writing your entries, e.g. ``vim``. Some editors require special options to work properly, see :doc:`FAQ <recipes>` for details. This value can either be a string such as the earlier ``"editor": "vim"`` example or ``"editor": ["vim", "+set ft=markdown"]`` if you want to pass arguments to the editor.
|
||||
if set, executes this command to launch an external editor for writing your entries, e.g. ``vim``. Some editors require special options to work properly, see :doc:`FAQ <recipes>` for details.
|
||||
- ``encrypt``
|
||||
if ``true``, encrypts your journal using AES.
|
||||
- ``tagsymbols``
|
||||
|
|
|
@ -61,7 +61,7 @@ Feature: Zapped bugs should stay dead.
|
|||
|
||||
Scenario: Title with an embedded period on DayOne journal
|
||||
Given we use the config "dayone.yaml"
|
||||
When we run "jrnl 04-24-2014: Ran 6.2 miles today in 1:02:03. I'm feeling sore because I forgot to stretch."
|
||||
When we run "jrnl 04-24-2014: "Ran 6.2 miles today in 1:02:03. I'm feeling sore because I forgot to stretch.""
|
||||
Then we should see the message "Entry added"
|
||||
When we run "jrnl -1"
|
||||
Then the output should be
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
from __future__ import unicode_literals
|
||||
from __future__ import absolute_import
|
||||
|
||||
from behave import given, when, then
|
||||
from jrnl import cli, install, Journal, util
|
||||
from jrnl import __version__
|
||||
|
@ -12,23 +15,11 @@ try:
|
|||
except ImportError:
|
||||
from cStringIO import StringIO
|
||||
import tzlocal
|
||||
import shlex
|
||||
|
||||
|
||||
def _parse_args(command):
|
||||
nargs = []
|
||||
concats = []
|
||||
for a in command.split()[1:]:
|
||||
if a.startswith("'") and a.endswith("'"):
|
||||
nargs.append(a.strip("'"))
|
||||
elif a.startswith("'"):
|
||||
concats.append(a.strip("'"))
|
||||
elif a.endswith("'"):
|
||||
concats.append(a.strip("'"))
|
||||
nargs.append(u" ".join(concats))
|
||||
concats = []
|
||||
else:
|
||||
nargs.append(a)
|
||||
return nargs
|
||||
def ushlex(command):
|
||||
return map(lambda s: s.decode('UTF8'), shlex.split(command.encode('utf8')))
|
||||
|
||||
|
||||
def read_journal(journal_name="default"):
|
||||
|
@ -62,7 +53,7 @@ def set_config(context, config_file):
|
|||
@when('we run "{command}" and enter "{inputs}"')
|
||||
def run_with_input(context, command, inputs=None):
|
||||
text = inputs or context.text
|
||||
args = _parse_args(command)
|
||||
args = ushlex(command)[1:]
|
||||
buffer = StringIO(text.strip())
|
||||
util.STDIN = buffer
|
||||
try:
|
||||
|
@ -74,7 +65,7 @@ def run_with_input(context, command, inputs=None):
|
|||
|
||||
@when('we run "{command}"')
|
||||
def run(context, command):
|
||||
args = _parse_args(command)
|
||||
args = ushlex(command)[1:]
|
||||
try:
|
||||
cli.run(args or None)
|
||||
context.exit_status = 0
|
||||
|
|
|
@ -12,6 +12,8 @@ import tempfile
|
|||
import subprocess
|
||||
import codecs
|
||||
import unicodedata
|
||||
import shlex
|
||||
|
||||
|
||||
PY3 = sys.version_info[0] == 3
|
||||
PY2 = sys.version_info[0] == 2
|
||||
|
@ -121,9 +123,7 @@ def get_text_from_editor(config, template=""):
|
|||
with codecs.open(tmpfile, 'w', "utf-8") as f:
|
||||
if template:
|
||||
f.write(template)
|
||||
editor = config['editor']
|
||||
args = editor if isinstance(editor, list) else editor.split()
|
||||
subprocess.call(args + [tmpfile])
|
||||
subprocess.call(shlex.split(config['editor']) + [tmpfile])
|
||||
with codecs.open(tmpfile, "r", "utf-8") as f:
|
||||
raw = f.read()
|
||||
os.close(filehandle)
|
||||
|
|
Loading…
Add table
Reference in a new issue