From a88459dc1cf087a666426b409df6377ec656e8c3 Mon Sep 17 00:00:00 2001 From: Manuel Ebert Date: Sun, 24 Nov 2013 11:29:45 -0800 Subject: [PATCH 1/2] Piping data into jrnl and multiline composing --- jrnl/jrnl.py | 7 +++++-- jrnl/util.py | 6 +++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/jrnl/jrnl.py b/jrnl/jrnl.py index 901507c2..96ac97b3 100755 --- a/jrnl/jrnl.py +++ b/jrnl/jrnl.py @@ -157,10 +157,13 @@ def cli(manual_args=None): journal = Journal.Journal(journal_name, **config) 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) else: - raw = util.py23_input("[Compose Entry] ") + raw = util.py23_read("[Compose Entry, press Ctrl+D to finish writing]\n") if raw: args.text = [raw] else: diff --git a/jrnl/util.py b/jrnl/util.py index 727f6043..d461015b 100644 --- a/jrnl/util.py +++ b/jrnl/util.py @@ -65,10 +65,14 @@ def prompt(msg): msg += "\n" STDERR.write(u(msg)) -def py23_input(msg): +def py23_input(msg=""): STDERR.write(u(msg)) return STDIN.readline().strip() +def py23_read(msg=""): + STDERR.write(u(msg)) + return STDIN.read() + def yesno(prompt, default=True): prompt = prompt.strip() + (" [Y/n]" if default else " [y/N]") raw = py23_input(prompt) From 0911c2e470f3465df267a6ecb1a6a4abebadcf9d Mon Sep 17 00:00:00 2001 From: Manuel Ebert Date: Sun, 24 Nov 2013 11:29:55 -0800 Subject: [PATCH 2/2] Docs & Version bump --- CHANGELOG.md | 1 + docs/usage.rst | 3 +++ jrnl/__init__.py | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 67a12dd8..37b419d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ Changelog ### 1.6 (November 5, 2013) +* __1.6.5__ Allows composing multi-line entries on the command line or importing files * __1.6.4__ Fixed a bug that caused creating encrypted journals to fail * __1.6.3__ New, pretty, _useful_ documentation! * __1.6.2__ Starring entries now works for plain-text journals too! diff --git a/docs/usage.rst b/docs/usage.rst index c17bd761..fec5cbb9 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -15,6 +15,9 @@ Composing mode is entered by either starting ``jrnl`` without any arguments -- w jrnl today at 3am: I just met Steve Buscemi in a bar! He looked funny. +You can also import an entry directly from a file:: + + jrnl < my_entry.txt Smart timestamps ~~~~~~~~~~~~~~~~ diff --git a/jrnl/__init__.py b/jrnl/__init__.py index 208872cf..81d5e4ab 100644 --- a/jrnl/__init__.py +++ b/jrnl/__init__.py @@ -7,7 +7,7 @@ jrnl is a simple journal application for your command line. """ __title__ = 'jrnl' -__version__ = '1.6.4' +__version__ = '1.6.5' __author__ = 'Manuel Ebert' __license__ = 'MIT License' __copyright__ = 'Copyright 2013 Manuel Ebert'