mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-10 16:48:31 +02:00
Piping data into jrnl and multiline composing
This commit is contained in:
parent
e541b6bf3c
commit
e801c62cef
2 changed files with 10 additions and 3 deletions
|
@ -157,10 +157,13 @@ def cli(manual_args=None):
|
||||||
journal = Journal.Journal(journal_name, **config)
|
journal = Journal.Journal(journal_name, **config)
|
||||||
|
|
||||||
if mode_compose and not args.text:
|
if mode_compose and not args.text:
|
||||||
if config['editor']:
|
if not sys.stdin.isatty():
|
||||||
|
# Piping data into jrnl
|
||||||
|
raw = util.py23_read()
|
||||||
|
elif config['editor']:
|
||||||
raw = get_text_from_editor(config)
|
raw = get_text_from_editor(config)
|
||||||
else:
|
else:
|
||||||
raw = util.py23_input("[Compose Entry] ")
|
raw = util.py23_read("[Compose Entry, press Ctrl+D to finish writing]\n")
|
||||||
if raw:
|
if raw:
|
||||||
args.text = [raw]
|
args.text = [raw]
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -65,10 +65,14 @@ def prompt(msg):
|
||||||
msg += "\n"
|
msg += "\n"
|
||||||
STDERR.write(u(msg))
|
STDERR.write(u(msg))
|
||||||
|
|
||||||
def py23_input(msg):
|
def py23_input(msg=""):
|
||||||
STDERR.write(u(msg))
|
STDERR.write(u(msg))
|
||||||
return STDIN.readline().strip()
|
return STDIN.readline().strip()
|
||||||
|
|
||||||
|
def py23_read(msg=""):
|
||||||
|
STDERR.write(u(msg))
|
||||||
|
return STDIN.read()
|
||||||
|
|
||||||
def yesno(prompt, default=True):
|
def yesno(prompt, default=True):
|
||||||
prompt = prompt.strip() + (" [Y/n]" if default else " [y/N]")
|
prompt = prompt.strip() + (" [Y/n]" if default else " [y/N]")
|
||||||
raw = py23_input(prompt)
|
raw = py23_input(prompt)
|
||||||
|
|
Loading…
Add table
Reference in a new issue