mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-06-29 22:16:13 +02:00
Add ability to put --edit partly through a cli entry to move it to the editor (#1091)
also add some functionality to test suite to see what the editor file contents were and make assertions about it
This commit is contained in:
parent
336936651f
commit
cfdd05358a
3 changed files with 56 additions and 5 deletions
11
jrnl/jrnl.py
11
jrnl/jrnl.py
|
@ -83,6 +83,10 @@ def _is_write_mode(args, config, **kwargs):
|
|||
)
|
||||
)
|
||||
|
||||
# Might be writing and want to move to editor part of the way through
|
||||
if args.edit and args.text:
|
||||
write_mode = True
|
||||
|
||||
# If the text is entirely tags, then we are also searching (not writing)
|
||||
if (
|
||||
write_mode
|
||||
|
@ -108,6 +112,8 @@ def write_mode(args, config, journal, **kwargs):
|
|||
if args.text:
|
||||
logging.debug("Write mode: cli text detected: %s", args.text)
|
||||
raw = " ".join(args.text).strip()
|
||||
if args.edit:
|
||||
raw = _write_in_editor(config, raw)
|
||||
|
||||
elif not sys.stdin.isatty():
|
||||
logging.debug("Write mode: receiving piped text")
|
||||
|
@ -157,10 +163,11 @@ def search_mode(args, journal, **kwargs):
|
|||
_display_search_results(**kwargs)
|
||||
|
||||
|
||||
def _write_in_editor(config):
|
||||
def _write_in_editor(config, template=None):
|
||||
if config["editor"]:
|
||||
logging.debug("Write mode: opening editor")
|
||||
template = _get_editor_template(config)
|
||||
if not template:
|
||||
template = _get_editor_template(config)
|
||||
raw = get_text_from_editor(config, template)
|
||||
|
||||
else:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue